Skip to content

Instantly share code, notes, and snippets.

@skydriver
Created July 10, 2014 13:49
Show Gist options
  • Save skydriver/f8691c20569b79a6bb2d to your computer and use it in GitHub Desktop.
Save skydriver/f8691c20569b79a6bb2d to your computer and use it in GitHub Desktop.
Restrict direct access to wp-login and wp-admin
function codeart_block_dashboard_from_non_super_admins()
{
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if( !is_super_admin() )
if( strpos($actual_link, 'wp-admin') !== false || strpos($actual_link, 'wp-login.php') !== false )
if( strpos($actual_link, 'admin-ajax.php') === false && strpos($actual_link, 'wp-login.php?action=logout') === false )
wp_redirect( get_bloginfo('home') . '/log-in/' );
}
add_action('init', 'codeart_block_dashboard_from_non_super_admins');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment