且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Wordpress用户列表中隐藏特定的管理员帐户

更新时间:2023-01-30 07:42:29

您可以在 functions.php 中使用自定义函数来执行此操作。
这是一个示例:

You can do this with a custom function in your functions.php. Here is an example :

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 == '<USERNAME OF OTHER ADMIN>') { 
    global $wpdb;
    $user_search->query_where = str_replace('WHERE 1=1',
      "WHERE 1=1 AND {$wpdb->users}.user_login != '<YOUR USERNAME>'",$user_search->query_where);
  }
}

或者您也可以使用插件; http://wordpress.org/plugins/user-role-editor/

Or you can use a plugin for this; http://wordpress.org/plugins/user-role-editor/