0

I have create a user role using Advance Access Manager wordpress plugin having role to see, add and remove users name as site_admin. When user login with his Id he is able to see the adminstrator and edit his profile. I remove that thing by using this code.

Remove Ability for Other Users to View Administrator in User List?

But the problem is the 'Adminstrator' hyperlink is still there. I want to remove that 'Adminstrator' hyperlink and in 'All' hyperlink the total count should be all user except the Adminstrator.

It shows

All(3) | Adminstrator(1)| Subscriber(1) | site_admin(1)

I want to remove 'Adminstrator' Hyperlink from this links and set count for 'All(2)'. Thanks in advance.

1 Answer 1

0

I think something like this should work just fine:

function my_views_users($args) {
    $hidden_role = 'administrator';  // it will hide filter with role 'administrator' - you can change it to some other role

    $users_counts = count_users();
    $total_users = $users_counts['total_users'] - $users_counts['avail_roles'][$hidden_role];

    $args['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    unset($args[$hidden_role]);
    return $args;
}
add_filter('views_users', 'my_views_users');

Of course you should add some if statement to disable this code, when user is logged in as admin (you don't want to hide users from admin, I guess).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.