我具有以下功能,但不知道如何在列表中添加多个电子邮件地址。
// Remove Different Admin Menu Links For A Specific User Profile
add_action('admin_menu', 'remove_admin_menu_links');
function remove_admin_menu_links(){
$user = wp_get_current_user();
if( $user && isset($user->user_email) && 'user@email.com' == $user->user_email ) {
remove_menu_page( 'tools.php' );
remove_menu_page( 'themes.php' );
remove_menu_page( 'options-general.php' );
remove_menu_page( 'plugins.php' );
remove_menu_page( 'users.php' );
remove_menu_page( 'edit-comments.php' );
remove_menu_page( 'page.php' );
remove_menu_page( 'upload.php' );
remove_menu_page( 'edit.php?post_type=page' );
remove_menu_page( 'edit.php?post_type=videos' );
remove_menu_page( 'edit.php' );
}
}
remove_theme_support( 'genesis-admin-menu' );
答案 0 :(得分:2)
创建一个电子邮件地址数组,并检查其是否存在:
add_action('admin_menu', 'remove_admin_menu_links');
function remove_admin_menu_links(){
$restrictedUsers = [
"someone@somewhere.com",
"user@email.com"
];
$user = wp_get_current_user();
if( $user && isset($user->user_email) && in_array($user->user_email, $restrictedUsers )) {
remove_menu_page( 'tools.php' );
remove_menu_page( 'themes.php' );
remove_menu_page( 'options-general.php' );
remove_menu_page( 'plugins.php' );
remove_menu_page( 'users.php' );
remove_menu_page( 'edit-comments.php' );
remove_menu_page( 'page.php' );
remove_menu_page( 'upload.php' );
remove_menu_page( 'edit.php?post_type=page' );
remove_menu_page( 'edit.php?post_type=videos' );
remove_menu_page( 'edit.php' );
}
}
remove_theme_support( 'genesis-admin-menu' );