Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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).

share|improve this answer
    
Thanks and its working also..... –  ksr89 Jun 21 '13 at 4:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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