[wp-trac] [WordPress Trac] #14834: wp_insert_user errors for users without e-mail addresses

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 10 13:04:29 UTC 2010


#14834: wp_insert_user errors for users without e-mail addresses
--------------------------+-------------------------------------------------
 Reporter:  clifgriffin   |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.0            
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 Greetings,
 In versions previous to WP3, it was possible to pass wp_insert_user an
 array with or without an e-mail address and the user was created without
 issue.

 In WP3, a check was added to determine whether or not the user already
 exists by their e-mail address.

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

 The problem with this check is that it matches the admin account if you
 pass it a null or blank e-mail address.  The admin account, being created
 by the installation script, does not start with an e-mail address.

 This has caused one of my plugins (Simple LDAP Login) to fail. To fix
 this, I had to do 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;
         }
         else
         {
                 return get_user_by('email', $email);
         }
 }
 endif;

 Please consider changing this behavior in future versions. I hate having
 to modify core functions to keep a plugin working. :)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14834>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list