[wp-trac] [WordPress Trac] #9891: wp_insert_user() ignores 'role' when creating user

WordPress Trac wp-trac at lists.automattic.com
Wed May 20 15:15:33 GMT 2009


#9891: wp_insert_user() ignores 'role' when creating user
-----------------------------+----------------------------------------------
 Reporter:  jammin23         |       Owner:  Denis-de-Bernardy                                   
     Type:  defect (bug)     |      Status:  new                                                 
 Priority:  normal           |   Milestone:  Unassigned                                          
Component:  Role/Capability  |     Version:                                                      
 Severity:  normal           |    Keywords:  wp_insert_user, role, registration, account creation
-----------------------------+----------------------------------------------
 In Wordpress 2.7.1 and possibly other versions, the documentation for
 wp_insert_user() claims that it accepts 'role' in the $userData array.
 This is not true when creating a user, only when updating an existing
 account.

 wp-includes/registration.php starting line 202:

         if ( $update && isset($role) ) {
                 $user = new WP_User($user_id);
                 $user->set_role($role);
         }

         if ( !$update ) {
                 $user = new WP_User($user_id);
                 $user->set_role(get_option('default_role'));
         }

 If the user is being created, the role is always set to the default role,
 not the one that was specified by the API call.

 This probably makes no odds at all within Wordpress, but I'm using a
 plugin (Simple LDAP Login) which needs to set role on account creation. A
 workaround of course is to set the role with wp_update_user() after
 creating the account, but this shouldn't be necessary according to the
 function's documentation.

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


More information about the wp-trac mailing list