Change WordPress user roles and capabilities › Forums › How to or FAQ › Promote users capability
- This topic has 3 replies, 2 voices, and was last updated 4 years ago by
abmex.
-
AuthorPosts
-
03/09/2021 at 14:46 #7676
abmex
ParticipantSorry, but this seems really complicated and confusing to me.
I need a user role that is able to promote (upgrade) users, let’s say from Subscriber to Contributor.So I’ve created a new role “Manager”, and gave this Manager role the capabilities ‘edit users’, ‘list users’, ‘promote users’.
Now when I log in as a “Manager”, then try to edit a user, I see not only a field “Role” with the dropdown options of the available user roles, but I also have an additional section on the user profile called “Additional Capabilities” with the 2 fields “Other Roles” and “Capabilities”.
This is super confusing when the “Manager” can change the user role on 2 different fields within a user profile.
BTW, the “User Role Editor” in “Custom Capabilities” in the URE settings for the “Manager” doesn’t have a single capability checked/enabled.
04/09/2021 at 03:42 #7678Vladimir
KeymasterUser Role Editor by default extends WordPress UI to allow grant more than single user role via “Other Roles” field. You can hide it adding this custom code to the active theme functions.php file:
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section'); add_filter('ure_bulk_grant_roles', 'ure_show_additional_capabilities_section'); function ure_show_additional_capabilities_section($show) { $user = wp_get_current_user(); if (in_array('user-manager', $user->roles)) { $show = false; } return $show; }
05/09/2021 at 12:23 #7679abmex
ParticipantThanks for trying to help, but this didn’t work.
This piece of code only removed the Capabilities field with the ‘edit capabilities” link, but the entire section “Additional capabilities” including the dropdown field “Other Roles” is still there.
https://www.dropbox.com/s/4m3dxb1yikwwvq2/Screen%20Shot%202021-09-05%20at%207.15.25%20AM.png?dl=0I only want the “Manager” role I’ve created to be able to change the user role of other users (let’s say from Subscriber to Contributor), but restrict it to a maximum of manager. I don’t want an extra field/section to assign ADDITIONAL roles or capabilities.
05/09/2021 at 12:34 #7680abmex
ParticipantOh never mind, I found that I need to update the ID of the user role in the code.
Works now.
Thanks again. -
AuthorPosts
- You must be logged in to reply to this topic.