Use custom ure_other_roles_access
filter to dynamically change restrictions set by “Other roles access” add-on for the roles granted to a current user. Filter takes 2 input parameters:
1) $blocked (array) – restrictions for roles granted to current user;
Array contains 2 elements:
‘access_model’: 1 – block selected roles, 2 – block not selected roles;
‘data’: array with list of selected roles, like $blocked[‘data’][0] = ‘author’, etc.
2) $user (WP_User) – current user.
Example below blocks for user with ‘user-manager’ role access to the roles: ‘user-manager’ and ‘users_administrator’.
// Other roles access add-on data for user add_filter( 'ure_other_roles_access', 'ure_other_roles_access', 10, 2 ); function ure_other_roles_access( $blocked, $user ) { if ( !in_array( 'user-manager', $user->roles ) ) { return $blocked; } $blocked['selected'] = 1; $blocked['data'][] = 'user-manager'; $blocked['data'][] = 'users_administrator'; return $blocked; } // end of ure_other_roles_access() |