Hide Dashboard for all except admin WITHOUT PLUGIN ! Bonus..
-
Hide Dashboard for all except admin WITHOUT PLUGIN !
Just add that code in your functions.php
- The file is in your theme folder ??
function remove_the_dashboard () { if (current_user_can('level_10')) { return;}else { global $menu, $submenu, $user_ID; $the_user = new WP_User($user_ID); reset($menu); $page = key($menu); while ((__('Dashboard') != $menu[$page][0]) && next($menu)) $page = key($menu); if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]); reset($menu); $page = key($menu); while (!$the_user->has_cap($menu[$page][1]) && next($menu)) $page = key($menu); if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2])) wp_redirect(get_option('siteurl') . '/wp-admin/post-new.php');}} add_action('admin_menu', 'remove_the_dashboard');
Et voila !
————————————————
+ + +
————————————————
BONUS 1 !Désactivate admin bar in site (front office) :
Just add that code in your functions.php
- The file is in your theme folder ??
add_filter('show_admin_bar','__return_false');
————————————————
+ + +
————————————————
BONUS 2 !Désactivate some menu, sub-menu or/and buttons of the admin bar :
Just add that code in your functions.php
- The file is in your theme folder ??
function edit_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); // This line deactivate WP logo and it menu. // if you want the logo but not the menu put this line : $wp_admin_bar->remove_menu('about'); // This line deactivate about link $wp_admin_bar->remove_menu('wporg'); // This line deactivate www.remarpro.com link $wp_admin_bar->remove_menu('documentation'); // This line deactivate the documentation link $wp_admin_bar->remove_menu('support-forums'); // This line deactivate the support-forum link $wp_admin_bar->remove_menu('feedback'); // This line deactivate the feedback link $wp_admin_bar->remove_menu('view-site'); // This line deactivate the sub-menu go to the site but not the button in the bar with the name of your site } add_action('wp_before_admin_bar_render', 'edit_admin_bar');
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Hide Dashboard for all except admin WITHOUT PLUGIN ! Bonus..’ is closed to new replies.