Created
December 9, 2020 12:46
-
-
Save smileBeda/883529d0f7a6be8993826f17db974d97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('init','safe_remove_backend_admin_access_for_role'); | |
function safe_remove_backend_admin_access_for_role(){ | |
if( current_user_can('editor') || current_user_can('administrator') )//Your roles | |
return; | |
if( is_admin() && !defined('DOING_AJAX') ){//IMPORTANT! Front end AJAX events are excluded... | |
if(isset( $_GET[ 'action'] ) && 'trash' == $_GET[ 'action'])//Perhaps you have a call to some WP Admin Operation that needs whitelisting... | |
return; | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment