Title: Multiple role when creating user doesn&#8217;t work
Last modified: May 30, 2022

---

# Multiple role when creating user doesn’t work

 *  Resolved [karbou](https://wordpress.org/support/users/karbou/)
 * (@karbou)
 * [4 years ago](https://wordpress.org/support/topic/multiple-role-when-creating-user-doesnt-work/)
 * I find something strange.
 * I Have a website, when i create user, i can allow multiple, but doesn’t work 
   when the user is create, but working when i do the same thing for an existing
   user. So it’s not working when user create but ok with existing user.
 * In your code, on /includes/admin-load.php you have this
 *     ```
       add_action('profile_update', [$this, 'action_profile_update'], 10, 2);
   
       if (is_multisite()) {
           add_action('add_user_to_blog', [$this, 'action_profile_update'], 9);
       } else {
           add_action('user_register', [$this, 'action_profile_update'], 9);
       }
       ```
   
 * So when a user is created or is updated, we use **action_profile_update**
 * And on this function we have this :
 *     ```
       // Check if we need to update the user's roles, allowing to set multiple roles.
       if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce(sanitize_key($_REQUEST['_wpnonce']), 'update-user_' . $userId) && isset($_POST['pp_roles']) && current_user_can('promote_users')) {
       ```
   
 * in my case, i don’t have $_REQUEST[‘_wpnonce’] but this $_REQUEST[‘_wpnonce_create-
   user’], this can work. And i’m not sure but the seconde condition ( wp_verify_nonce(
   sanitize_key($_REQUEST[‘_wpnonce’]), ‘update-user_’ . $userId) ) can working 
   when user is creating.
 * If i replace this
    `if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce(sanitize_key(
   $_REQUEST['_wpnonce']), 'update-user_' . $userId) && isset($_POST['pp_roles'])&&
   current_user_can('promote_users')) {`
 * by this
 * `if (isset($_POST['pp_roles']) && current_user_can('promote_users')) {`
 * but it’s obviously not the good solution
 * Thanks for your time.
    -  This topic was modified 4 years ago by [karbou](https://wordpress.org/support/users/karbou/).
    -  This topic was modified 4 years ago by [karbou](https://wordpress.org/support/users/karbou/).

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

 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [4 years ago](https://wordpress.org/support/topic/multiple-role-when-creating-user-doesnt-work/#post-15692854)
 * Hi [@karbou](https://wordpress.org/support/users/karbou/)
 * Thanks for using PublishPress Capabilities.
 * Sorry, that question isn’t clear.
 * We can’t help with custom code for Free users here on WordPress.org, but we may
   be able to give you some guidance if the question is clearer.
 *  Thread Starter [karbou](https://wordpress.org/support/users/karbou/)
 * (@karbou)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/multiple-role-when-creating-user-doesnt-work/#post-15794569)
 * Sorry if i’m not clear, i talking about the free version, but this bug must be
   the same with the pro version. The code isn’t a custom code, it’s a solution 
   i can find to fix this, temporarily. But let me explain the probleme just with
   your code.
 * My problem is this. I want to allow multiple role for a user.
    Case 1: Basic 
   case – I create a user, i choose his role – After saved this user, i edit them
   and now i can add multiple role.
 * Case 2 : PP_CAPABILITIES_ADD_USER_MULTI_ROLES defined
    – I define PP_CAPABILITIES_ADD_USER_MULTI_ROLES–
   I create a user and choose multiple role, contributor, editor – After i saved
   this user, his role is wrong, he’s currently administrator and i need to change
   this role on a second time, and after that, his role is good.
 * So, Case 1 is OK, but i would like to save multiple role when i creating a user.
   So i use PP_CAPABILITIES_ADD_USER_MULTI_ROLES and case 2. But in this case, it’s
   not work perfectly. And in this case, for me, the problem is in includes/admin-
   load on line 355
 * `if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce(sanitize_key($_REQUEST['
   _wpnonce']), 'update-user_' . $userId) && isset($_POST['pp_roles']) && current_user_can('
   promote_users')) {`
 * Because in my request, i don’t have **_wpnonce** but this **_wpnonce_create-user**
   and obviously, when you check the, it’s not gonna work. And Publish Press can’t
   handle a case with **_wpnonce_create-user**
 * For you, it’s a probleme with an another plugin or, Publish Press, should work
   with a request like _wpnonce_create-user ?
 * Thaks a lot and i hope i am more clear
 * Best regards
    Matt
 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/multiple-role-when-creating-user-doesnt-work/#post-15798990)
 * [@karbou](https://wordpress.org/support/users/karbou/) Thanks for the feedback.
 * We’re going to improve this code in the next release of Capabilities and allow
   new users to have multiple roles.

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

The topic ‘Multiple role when creating user doesn’t work’ is closed to new replies.

 * ![](https://ps.w.org/capability-manager-enhanced/assets/icon-256x256.png?rev=
   3568949)
 * [PublishPress Capabilities - User Role Editor, Access Permissions, User Capabilities, Admin Menus](https://wordpress.org/plugins/capability-manager-enhanced/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/capability-manager-enhanced/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/capability-manager-enhanced/)
 * [Active Topics](https://wordpress.org/support/plugin/capability-manager-enhanced/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/capability-manager-enhanced/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/capability-manager-enhanced/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/multiple-role-when-creating-user-doesnt-work/#post-15798990)
 * Status: resolved