Removing the dashboard:
/* Remove the "Dashboard" from the admin menu for non-admin users */
function wpse54085_remove_dashboard () {
global $current_user, $menu, $submenu;
get_currentuserinfo();
if( ! in_array( \'administrator\', $current_user->roles ) ) {
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 ( ! $current_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\', \'wpse54085_remove_dashboard\' );
Removing further parts of the admin menu:
在这里,您可以使用
remove_menu_page()
作用
function wpse54085_admin_menu_fixes() {
global $current_user;
if( ! in_array( \'administrator\', $current_user->roles ) ) {
remove_menu_page(\'link-manager.php\');
/* add more menu pages, depending on what you want to remove */
}
}
add_action( \'admin_menu\', \'wpse54085_admin_menu_fixes\' );
显然,这两种功能都可以扩展以区分其他用户角色。这两者都应该添加到主题的函数中。php文件。