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) && '[email protected]' == $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('[email protected]','[email protected]')) == $user->user_email ) {

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

1 Answer 1

1

Correct usage:

$arr = array('[email protected]','[email protected]');
in_array($user->user_email, $arr)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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