Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box

You can do this more simply by using the pre_get_users hook, grab the search string extract the role from it and add that as a role parameter for WP_User_Query. Edited my original code, here’s a refined version, bit cleaner. Additional edit: Scroll further down for update (see follow-up). class wpse_410251_user_search { private $role = false; … Read more