1

I've got 3 admin users and would like to modify admin menu for 2 of them by their email address, not by role (since the capabilities are all the same).

This works with a single email address:

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@domain.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');
    }
}

What's the proper syntax for listing an array of email addresses?

I've tried the option below. It does nothing at all, stops working but no error either.

if( $user && isset($user->user_email) && (in__array('user1@domain.com','user2@domain.com')) == $user->user_email ) {

  • the function in_array is with 1 underscore and works like that : php.net/in_array – mmm Oct 27 '17 at 17:10
1

Correct usage:

$arr = array('user1@domain.com','user2@domain.com');
in_array($user->user_email, $arr)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.