WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#17967 closed defect (bug) (worksforme)

Ignoring the user ID in wp_create_user

Reported by: mostafa.s1990 Owned by: Mostafa Soufi
Milestone: Priority: normal
Severity: normal Version: 3.1.4
Component: Users Keywords: reporter-feedback
Focuses: Cc:

Description

Hello
If you use this function, Ignores old users.
The new user will replace the previous
With all the information
wp_create_user

Change History (4)

comment:1 scribu3 years ago

  • Keywords reporter-feedback added; needs-testing removed

Please provide some example code that demonstrates this behaviour.

comment:2 mostafa.s19903 years ago

Replying to scribu:

Please provide some example code that demonstrates this behaviour.

	// variable for test
	$user_name	=	$_POST['author_user_name'];
	$password	=	wp_generate_password();
	$email		=	$_POST['author_user_email'];
	
	// function test
	$user_id	=	wp_create_user($user_name, $password, $email) ;

	// check error
	if ( is_wp_error($user_id) ){
		$register_error = $user_id->get_error_message();
		echo $register_error;
	} else {
		_e('Thankd!');
	}
Last edited 3 years ago by mostafa.s1990 (previous) (diff)

comment:3 dd323 years ago

check to see if the user exists before creating a user: username_exists($username)

I cant reproduce this however.

this:
var_dump( wp_create_user('admin', 'password', 'test2@localhost') );

results in:
object(WP_Error)[104]
  public 'errors' => 
    array
      'existing_user_login' => 
        array
          0 => string 'This username is already registered.' (length=36)
  public 'error_data' => 
    array
      empty

comment:4 SergeyBiryukov3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Can't reproduce either.

Feel free to reopen with more information if there's still a problem.

Note: See TracTickets for help on using tickets.