Blocking WordPress Backend and Top Bar Access
To prevent unauthorized users from accessing the WordPress backplane:
wpse_11244_restrict_admin() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( __('You are not allowed to access this part of the site') ); } } add_action( 'admin_init', 'wpse_11244_restrict_admin', 1 );
To allow an unwanted user accessing the WordPress backplane to access the homepage:
function wpse_11244_restrict_admin() { if ( ! current_user_can( 'manage_options' ) && $_SERVER['PHP_SELF'] != '/wp-ajax./phpurl1; { } } add_action( 'admin_init', 'wpse_11244_restrict_admin', 1 );
To block the appearance of the WordPress admin top bar and menu:
<?php show_admin_bar(false); ?>
Just add it to your theme's .functions.php file.
As a last alternative, if you want the admin bar to be visible only to administrators and closed to all other roles:
add_action('after_setup_theme', 'remove_admin_bar');function remove_admin_bar() { if (!current_user_can('administrator') && !is_admin() {bar(show)) } }
Just add the codes to your theme's .functions.php file.
0 Comments