WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know the former allows additional parameters, so you can more user info, but other then that, why do both exist?

The specific reason I want to know is that wp_insert_user() is happening REALLY slowly. Somewhere between 5 - 10 seconds. I don't remember having this problem in the past, when I was using create_user, so I'm wondering if there's a lot more happening behind the scenes with one as opposed to the other.

Thanks.

share|improve this question
up vote 4 down vote accepted

None. The whole source of wp_create_user() is:

function wp_create_user($username, $password, $email = '') {
    $user_login = esc_sql( $username );
    $user_email = esc_sql( $email    );
    $user_pass = $password;

    $userdata = compact('user_login', 'user_email', 'user_pass');
    return wp_insert_user($userdata);
}

It just calls insert version almost immediately, basically a shorthand wrapper. As for why it exists - core works in mysterious ways and (short of hunting down developer by version control history and asking) there is rarely way to tell. :)

share|improve this answer

As per Codex

The wp_create_user function allows you to insert a new user into the WordPress database. It uses the $wpdb class to escape the variable values, preparing it for insertion into the database. Then the PHP compact() function is used to create an array with these values. To create a user with additional parameters, use wp_insert_user().

So the main difference would be that with wp_insert_user you may pass more than just ($username, $password, $email).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.