I want to create custom role ('sales') that can edit user profiles of 'subscribers' but can not change the role of that user.
The user details that would be editable by the 'sales' role would be resetting password and interacting with some custom user-meta fields.
Is it possible to edit capabilities at that level of granularity?
I want to create custom role ('sales') that can edit user profiles of 'subscribers' but can not change the role of that user.
The user details that would be editable by the 'sales' role would be resetting password and interacting with some custom user-meta fields.
Is it possible to edit capabilities at that level of granularity?
Share Improve this question asked Dec 6, 2019 at 10:55 Pog Le PogPog Le Pog 33 bronze badges1 Answer
Reset to default 0I am not sure if there is something native. However you could get really hacky if you wanted to if no other option.
You could create a css class to be inserted based on the current user role that is logged in. Then target that role (being sales for example) and hide that form field.
You could use something like this:
function sales_role_admin_body_class( $classes ) {
global $current_user;
foreach( $current_user->roles as $role )
$classes .= ' role-' . $role;
return trim( $classes );
}
add_filter( 'admin_body_class', 'sales_role_admin_body_class' );
Then you could target it something like this in your css:
.role-sales #form_field_id_you_want_to_hide{
display: none !important;
}
Purely an example and very hacky. However it would work if no other option.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744933001a4601850.html
评论列表(0条)