Title: wp_insert_user function User Roles
Last modified: August 19, 2016

---

# wp_insert_user function User Roles

 *  [isimpledesign](https://wordpress.org/support/users/isimpledesign/)
 * (@isimpledesign)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_user-function-user-roles/)
 * Hi i am using the wp_insert_user function
 *     ```
       wp_insert_user( array ('ID' => $user_id,
       					   'user_url' => $website,
       					   'user_login' => $user_name,
       					   'user_pass' => $random_password,
       					   'user_email' => 'example@hotmail.co.uk',
       					   'user_login' => $user_name,
       					   'first_name' => 'Samuel',
       					   'last_name' => 'East',
       					   'role' => 'Administrator'
       					   ) ) ;
       }
       ```
   
 * everything works great apart from ‘role’ => ‘Administrator’ when i set it to 
   this it says none.
 * In the codex it says
    role A string used to set the users role.
 * Can anyone explain why this doesnt work i have tried user levels???

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [havahula](https://wordpress.org/support/users/havahula/)
 * (@havahula)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_user-function-user-roles/#post-1929400)
 * This function has been working for me until yesterday. This looks like a bug 
   and not sure if it’s related to updates in 3.1.3 – 3.2 but assigning a role using‘
   Contributor’ or ‘contributor’ as well as not defining the role and relying instead
   upon the default role setting results in a “none” being assigned to the role.
 * Thoughts anyone?
 *  [havahula](https://wordpress.org/support/users/havahula/)
 * (@havahula)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_user-function-user-roles/#post-1929401)
 * actually not a bug. it looks like sanitize_meta() has been updated to be more
   specific and that caused an issue with insertion of the role as part of an array
   of data.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wp_insert_user function User Roles’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [havahula](https://wordpress.org/support/users/havahula/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_user-function-user-roles/#post-1929401)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
