capabilities - Create role that can edit some user details, but not the role

I want to create custom role ('sales') that can edit user profiles of 'subscribers' but can not chan

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

I 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信