Emman Z
Emman Z

Reputation: 171

How to filter views_edit in user list table?

The following is a screenshot of the users list table in the dashboard. I'd like to customize highlighted part:

enter image description here

I know how do it in the posts list table using the method explained in this WordPress Answer.

I tried to use filter views_edit-user but nothing happened. I also tried to Google it but it seems this filter doesn't have documentation or is not really a WordPress filter.

How to customize that admin section using add_action or add_filter?

Upvotes: 10

Views: 7417

Answers (1)

brasofilo
brasofilo

Reputation: 26065

The hook for that screen is based on 'views_' . $this->screen->id, so it should be:

add_filter( 'views_users', 'modify_views_users_so_15295853' );

function modify_views_users_so_15295853( $views ) 
{
    // Manipulate $views

    return $views;
}

The content of $views in my system is:

Array
(
    [all] => <a href='users.php' class="current">All <span class="count">(7)</span></a>
    [administrator] => <a href='users.php?role=administrator'>Administrator <span class="count">(1)</span></a>
    [editor] => <a href='users.php?role=editor'>Editor <span class="count">(1)</span></a>
    [subscriber] => <a href='users.php?role=subscriber'>Subscriber <span class="count">(5)</span></a>
)

Upvotes: 15

Related Questions