On People List, we have good filters Role, Permission and Status but we do not have a query filter (ala google search) to filter the list table by username. For example if we want to find all test users that has test on their username (eg. testuser, usertest, thetestboy) and we do not know their current status nor role nor permission. It will be cumbersome to look for it and trying all the filters and we have for example 1000's of users.

Or, we created additional field firstname or lastname or anothernewfieldname and we wanted it to be filtered by that criteria.

Though we can do hook_form_alter to add our controls like textfields, we do not have a control on how the query on user list will be run. It will be a good idea IMO to be able to hook on the query before it is run on user_admin_account.

I have implemented it on my development environment.

On my environment I have edited the user.admin.inc, and inserted the code after line 162 user_build_filter_query($query);

and added my code of

foreach (module_implements('user_custom_condition') as $module) {
if ($module == 'user') continue; //skip if self
$function = $module . '_user_custom_condition';
$function($query); //add additional filters from other module implementation
}

with that change I can do form alter for user_filter_form and create a button that will submit on my custom function like peoplesearch_submit($form, &$form_state) and inside it I added session variables for I can use it on peoplesearch_user_custom_condition later on. And redirect the form to admin/people.

Then on my peoplesearch_user_custom_condition(&$query) wherein $query is passed by reference.

I can do my additional leftJoin to firstname field, lastname field and apply my condition to username, firstname and lastname field. and I can use my session variables that I saved earlier.

And when the query for user list has been done my custom query will be applied into it.

I hope you get the idea.

Thanks!

Comments

Version: 7.0 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.