Last active
December 20, 2015 08:49
-
-
Save denishvachhani/6103731 to your computer and use it in GitHub Desktop.
Hide Dashboard for all except admin WITHOUT PLUGIN !
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
<?php | |
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'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment