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.

What is the correct way to add a custom filter (a dropdown box in this case) to the admin user list (wp-admin/users.php)?

There are no filters or actions that I see to hook into that would allow me to output a select box.

I know I can inject it via javascript, but I'm hoping there's a way to do it on the PHP side.

I am planning on using the results of that filter int as outlined here: How to search all user meta from users.php in the admin

share|improve this question
    
Looked at the code...you're right...there's no actions or filters in the whole process of generating that table view. The only one is for the role links (the little ones top left). –  wyrfel Feb 24 '11 at 7:44
    
Maybe there is some overarching filter that passes in the entire page output and I can add it via regexp? –  John Feb 24 '11 at 14:59
add comment

1 Answer

up vote 1 down vote accepted

Actually found a potential way (with WP3.1), but it's a bit more involved than using filters:

Since WP3.1 now uses the WP_List_Class to generate the admin pages, you can create your own My_User_List_Table class, inheriting from WP_Users_List_Table and in that class override the extra_tablenav() method. In your own method you duplicate the code from WP_Users_List_Table::extra_tablenav() and add your own stuff.

Then you create a duplicate of wp-admin/users.php, modify it to use your class instead and modify the users menu entry in the admin navigation to call your duplicate instead of wp-admin/users.php. I'm not sure if WP3.1 now comes with easier methods to do that then the hacky solutions necessary for WP3.0.

Unfortunately, all this new WP_List_Class stuff comes without good action or filter hooks, it would have been so easy had they added an apply_filters() call to _get_list_table(). Grmpf.

share|improve this answer
add comment

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.