Php WordPress用户数

Php WordPress用户数,php,wordpress,Php,Wordpress,如何从WordPress用户数中减去1,以便隐藏的管理员用户不会被计算在内 我可以把计数全部隐藏起来,但我宁愿从计数中减去1 将代码插入Functions.php不确定为什么要隐藏count,而是用户页面上实际隐藏的管理员配置文件 add_filter("views_users", 'editCounts', 10, 1); function editCounts($views) { if ( current_user_can( 'administrator' ) ) {

如何从WordPress用户数中减去1,以便隐藏的管理员用户不会被计算在内

我可以把计数全部隐藏起来,但我宁愿从计数中减去1


将代码插入Functions.php

不确定为什么要隐藏count,而是用户页面上实际隐藏的管理员配置文件

add_filter("views_users", 'editCounts', 10, 1);
function editCounts($views) {
    if ( current_user_can( 'administrator' ) ) {
        $total = count_users();
        $newTotal = $total['total_users']-1;
        $views = array('all' => '<a href="users.php" class="current" aria-current="page">All <span class="count">('.$newTotal.')</span></a>', 'administrator' => '<a href="users.php?role=administrator">Administrator <span class="count">('.$newTotal.')</span></a>');
        return $views;
    }else{
        return $views;
    }
}  
我已经按你的要求做了减法运算。将此代码放入functions.php并访问用户页面

add_filter("views_users", 'editCounts', 10, 1);
function editCounts($views) {
    if ( current_user_can( 'administrator' ) ) {
        $total = count_users();
        $newTotal = $total['total_users']-1;
        $views = array('all' => '<a href="users.php" class="current" aria-current="page">All <span class="count">('.$newTotal.')</span></a>', 'administrator' => '<a href="users.php?role=administrator">Administrator <span class="count">('.$newTotal.')</span></a>');
        return $views;
    }else{
        return $views;
    }
}  
添加过滤器(“视图用户”,“编辑计数”,10,1);
函数editCounts($views){
如果(当前用户可以(“管理员”)){
$total=count_users();
$newTotal=$total['total_users']-1;
$views=array('all'=>'','administrator'=>'');
返回$views;
}否则{
返回$views;
}
}  

希望对您有所帮助

如何知道管理员被隐藏?您已经在使用自定义函数了吗?谢谢!你真棒!它工作得很好!