#9891 closed defect (bug) (fixed)
wp_insert_user() ignores 'role' when creating user
Reported by: | jammin23 | Owned by: | Denis-de-Bernardy |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Role/Capability | Keywords: | has-patch wp_insert_user, role, registration, account creation |
Focuses: | Cc: |
Description
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.
please give the attached patch a shot