Nice to meet you.
I use wp-members with Wordpress to manage users.
When there is information that I want to be displayed only to a specific user among the logged-in users,
As shown below, the user IDs 1, 2, and 3 are set, but only 1 is displayed.
Is the ID specification method incorrect?

global $current_user;
  get_currentuserinfo ();
  if ($current_user->ID == "1,2,3") {
    echo ' test ';
  • Answer # 1


    $current_user->ID == "1,2,3"

    in_array ($current_user->ID, [1,2,3])

    How about it?
    If $current_user->ID type is fixed, strict comparison is better

    For example

    $ID = "1a";
    var_dump (in_array ($ID, [1,2,3]));// returns true

Related articles