1

This is my code and I dont know why isnt working

add_action('admin_menu', 'hide_a_menu');
function hide_a_menu() {
    global $current_user;
    $user_id = get_current_user_id();
    if($user_id == '41') {
        remove_menu_page( 'edit-comment.php' );
    }
}
1
  • For information, the get_current_user_id() function returns an integer. Apr 18, 2021 at 21:23

1 Answer 1

1

You misspelled the name edit-comment.php try the below code.

add_action('admin_menu', 'hide_a_menu');
function hide_a_menu() {
    global $current_user;
    $user_id = get_current_user_id();
    if($user_id == '41') {
        remove_menu_page( 'edit-comments.php' );
    }
}

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.