Advertisement
s2prod

Hide a wordpress admin from other users

Feb 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. //Add code at below to your functions.php file
  2.  
  3. add_action('pre_user_query','yoursite_pre_user_query');
  4. function yoursite_pre_user_query($user_search) {
  5. global $current_user;
  6. $username = $current_user->user_login;
  7.  
  8. if ($username == 'YOUR_USER_ID') {
  9. global $wpdb;
  10. $user_search->query_where = str_replace('WHERE 1=1',
  11. "WHERE 1=1 AND {$wpdb->users}.user_login != 'YOUR_USER_ID'",$user_search->query_where);
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement