• Resolved mdfrederickjr

    (@mdfrederickjr)


    Thank you for the plugin, it’s an excellent addition to the WordPress Community, especially for some of using WordPress as a platform.

    For our own purposes we wanted some finer grain control around who can switch to who.

    We made two customizations, one of which I’m lobbying you to put into the plugin.

    1) Using a filter on user_has_cap – We were able to add the capabilities switch_to_user and switch_off for users with a different capability than edit_users.

    2) Added the following filter to the switch_to_user function, right after the $old_user_id variable is defined. This is what seems like it would be a nice added feature for customizability.

    `if($set_old_user){
    $allowed = apply_filters(‘user_can_switch’, TRUE, $old_user_id, $user_id);
    if(!$allowed){
    return false;
    }
    }`

    We then hook into it and disallow users from switching to another user that is an Administrator.

    Thanks!

    https://www.ads-software.com/plugins/user-switching/

Viewing 1 replies (of 1 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Thanks for the feedback. Glad you find the plugin useful!

    1) This is already possible by unhooking the existing filter and adding your own. Take a look at the User Switching for Regular Admins plugin to see how that implements it.

    2) This is already possible, too, via the switch_to_user capability check in the action_init() method, which gets passed the user ID.

Viewing 1 replies (of 1 total)
  • The topic ‘Feature switch_to_user filter’ is closed to new replies.