Skip to content

Instantly share code, notes, and snippets.

@remkus
Created October 14, 2012 12:18
Show Gist options
  • Select an option

  • Save remkus/3888385 to your computer and use it in GitHub Desktop.

Select an option

Save remkus/3888385 to your computer and use it in GitHub Desktop.
No WordPress Dashboard Access
add_action( 'init', 'no_wp_admin_for_lesser_gods' );
/**
* This will redirect anyone without an administrator
* lever user to the front of the site. No Dashboard for them.
*
* @author Remkus de Vries
* @access public
*
*/
function no_wp_admin_for_lesser_gods() {
if ( is_admin() && ! current_user_can( 'administrator' ) ) {
wp_redirect( home_url() );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment