WordPress Hack #2: Protect Your Admin

Ever wanted to protect your admin area from access by non-admin users? Try adding this to your functions.php.

add_action('auth_redirect','custom_admin_access');
function custom_admin_access() {
global $current_user;
   if( !current_user_can('manage_options') && is_admin() ) {
      wp_redirect( home_url() );
   }
}

Comments

  1. Kabul says:

    I was shcearing for this kind of a plugin for such a long time.Thanks WPMUDEV for this plugin and Siobhan for this post .   

Speak Your Mind

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.