I want to restrict wordpress admin to view all users in user list.

For say, I have created custom roles (company users, employee). A company user type role can have multiple employees.

I want wordpress admin to only view company users.

I got, args in function prepare_items() inside WP_Users_List_Table class can filter this. So have tried to override this in my theme's functions.php.

function my_prepare_items(){

    //my custom code goes here

add_action( 'prepare_items', 'my_prepare_items' );

But it's not working. How and where I can override this functionality without touching core wordpress methods?

EDIT : This I want in admin UI.

Thanks in advance.

  • Why don't you simply click the role links on the top side of the table? They are exactly there for filtering that list... – kaiser Jul 1 '14 at 14:58
  • Its okay but I want to show only one role and dont show other roles – Pradeep Singh Jul 2 '14 at 5:01
  • Does it have to be non-hackable (and every other role just locked away) or would it be enough to point the menu link to exactly this role filter per default? – kaiser Jul 2 '14 at 9:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.