Ad Code

Changing the default user search form on Moodle 2.4.3

For Moodle 2.7 in moodle\user\filters\lib.php locate the class user_filtering

in that class locate the function user_filtering

In there is a section of code

if (empty($fieldnames)) { $fieldnames = array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'email' => 1, 'city' => 1, 'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'username' => 1, 'auth' => 1, 'mnethostid' => 1); }

In there the values with a 0 are shown by default and the values with a 1 are shown when you press the show more button.

I have changed it so realname and username are set to 0 which shows both

if (empty($fieldnames)) { $fieldnames = array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'email' => 1, 'city' => 1, 'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'username' => 0, 'auth' => 1, 'mnethostid' => 1); }

Unfortunately you would need to set this after every update as it is a change to a core file.

Obviously changing a core file is less than ideal and can break things if you are not careful.

- End -

 

$SESSION->user_filtering = array();

towards the top of moodle\admin\user.php  after the optional_param checks it will reset the filters after the page has updated.

It will still show you active filters and the remove selected and remove all filters buttons but you will not need to press them as they will have no effect. You can just do a new search with whatever filters you want and the currently "active" ones will not be included.

 


 

Post a Comment

0 Comments