Hi friends, this is a very quick WordPress tutorial which demonstrates how to restrict admin panel to administrators access only.
This is the best idea to keep away your website users from admin area access. This is the very simple function which restricts non-admin users to visit the administrator screens.
Open functions.php file and copy paste below code at the end of the file and save it.
if (!array_key_exists('administrator', $current_user->caps))
wp_redirect( get_bloginfo('url') );
add_action('admin_init', 'restrict_admin_access', 1);
If you like this tutorial, share this with your friends via social media channel and also subscribe our newsletter to get the best tutorials directly in your email inbox.