Created
February 6, 2015 21:14
-
-
Save greenhornet79/947276fe0198046c8b57 to your computer and use it in GitHub Desktop.
Hide WordPress admin from subscribers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove admin bar from free users | |
add_action('after_setup_theme', 'remove_admin_bar'); | |
function remove_admin_bar() { | |
if (!current_user_can('administrator') && !is_admin()) { | |
show_admin_bar(false); | |
} | |
} | |
// don't allow users to access WordPress admin | |
add_action('admin_init', 'no_mo_dashboard'); | |
function no_mo_dashboard() { | |
if ( ! current_user_can( 'manage_options' ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { | |
wp_redirect(home_url()); exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment