Support » Plugins » wp_insert_user in WP 3.0

Viewing 12 replies - 1 through 12 (of 12 total)
  • No one have any input on this?

    I really need an answer.

    <shameless bump>

    I’m needing a fix as well. This was not an issue in earlier versions of WP. I’m importing users from another CMS which allows for duplicate email addresses.

    Ok, so further testing shows that I’m actually receiving the user id back from the call to wp_insert_user(), but the user is still not being created. No clue on this one.


    `$userId = wp_insert_user( $userdata );
    if ( is_wp_error($temp) ) :
    echo $userId->get_error_message() . ‘
    else :
    echo $userId . ‘

    Looks like my code block got borked. Another try:

    $userId = wp_insert_user( $userdata );
    if ( is_wp_error($temp) ) :
        echo $userId->get_error_message();
    else :
        echo $userId;

    I see the error in the if statement $temp should be $userId. Fixed it and still same result.

    Looks like I’ve hijacked this thread so this will be my last post. Found the issue. Was just misunderstanding the function. If you predefine the id for the user, wp looks for that id in order to update it in the DB. I thought it would create the user with that specific id.

    No worries, Ryan.

    I still haven’t found any good solution on this.

    Hi Clifgriffin, I have the same problem. I have two days importing users and not working well.

    At least I know that is by empty email……

    Have you fixed it? If I fix it, I tell you.

    I have solved the issue.
    I have modified the file wp-includes/registration.php
    I have commented the line 143 and 144.

    //if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) )
         //return new WP_Error('existing_user_email', __('This email address is already registered.') );

    Now, the function wp_insert_user don’t check if the email field is empty.

    I considered that solution, but I really want to make my plugin work with WP3+ without modifying or replacing wp_insert_user.

    Anyone else have input? I might just have to cave in.

    I fixed this without modifying wp_insert_user.

    I noticed that get_user_by_email is the function that returns “true” and throws everything off and that it is pluggable. So I did this:

    if ( !function_exists('get_user_by_email') ) :
     * Retrieve user info by email.
     * @since 2.5
     * @param string $email User's email address
     * @return bool|object False on failure, User DB row object
    function get_user_by_email($email) {
    	if(strlen($email) == 0 || empty($email) || $email == "" || strpos($email, "@") == false)
    		return false;
    		return get_user_by('email', $email);

    Basically, this prevents the admin account from returning as a duplicate for any user being created without an e-mail address.

    now wp-includes/registration is gone in 3.1 anyone no how to access the registration functions

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘wp_insert_user in WP 3.0’ is closed to new replies.