'How to hide some users from others users in Paid Membership Listing Page

I have searched the topic and found some answers on how to hide WP admin user form others related to wordpress core. Although it works for WP, I tried modifying the code by selecting the Paid Membership Pro Plugin database, table and user_id to hide ... but I'm missing something.

here is what I tried

add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
  global $current_user;
  $username = $current_user->user_id;

  if ($username == '4') { 
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->pmpro_memberships_users}.user_id != '1'",$user_search->query_where);
  }
}

The issue is that the Administrator shares a user level with another. But I want to prevent the other user from seeing the Administrator, and preferably ALL administrators from the pmpro-memberslist List page Any help to achieve this will be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source