Answers for "creat user function in wp"

PHP
0

wp_create_user

function wp_create_user( $username, $password, $email = '' ) {
    $user_login = wp_slash( $username );
    $user_email = wp_slash( $email );
    $user_pass  = $password;
 
    $userdata = compact( 'user_login', 'user_email', 'user_pass' );
    return wp_insert_user( $userdata );
}
Posted by: Guest on September-01-2021
0

wp create user programmatically

$result = wp_create_user('johndoe', 'passwordgoeshere', '[email protected]');
if(is_wp_error($result)){
  $error = $result->get_error_message();
  //handle error here
}else{
  $user = get_user_by('id', $result);
  //handle successful creation here
}
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language