wp_insert_user function User Roles (3 posts)

  1. isimpledesign
    Posted 4 years ago #

    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???

  2. havahula
    Posted 4 years ago #

    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?

  3. havahula
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic