I want to restrict wordpress custom role to view only specific users in user list.
I have created custom roles (sales). A sales role can view only specific role in the table.
You need to assign the capability to the sales role by using the following logic,
function add_theme_caps() {
// gets the author role
$role = get_role( 'sales' );
// This only works, because it accesses the class instance.
// would allow the author to edit others' posts for current theme only
$role->add_cap( 'list_users' );
}
add_action( 'admin_init', 'add_theme_caps');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.