2021-01-10 14:46:00

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

FilterRemove WP Admin Access for any role

Remove WP Admin Access

With this filter you can remove access – both visually and programmatically – to the WP Admin for any role defined. Usually you’d install a whole plugin for this feature but in fact it doesn’t need a plugin with lots of overhead.

This code also considers AJAX Events, and it can be adapted to any user role or further condition.

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;
      }
}