Restrict which users can be switched TO?

[ad_1]

Hello,

Is there a way I’m missing to restrict which users can be switched to? For example allow switching to users with an author role but not an editor role.

I’m hooking into switch_to_user, but at that time the switching has already happened. I can run checks at that point and force the user to logout, but I’d like to prevent the switching in the first place.

It would be great to have a hook like before_switch_to_user( $to_user_id, $from_user_id) somewhere near // Check authentication and // Check intent that would allow me to set my own logic and return a pass/fail.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer