Adding search and advanced filtering options to Drupal’s users list

In this post – we’ll show you how to create such views , step by step, and resolve this on your own.
Notice that this solution does not require a use of another module besides views.

user-search01

In this image, we can see the default user list which available under Drupal 7 administration.

For simple sites that maintain small amount of users – it is actually good enough for user maintenance.

But what happens in sites that reach hundreds or even thousands of registered users ?
In time it become real hard to be able to find and pick of the specific users without searching option.

However – the solution to this issue is surprisingly simple, by using Drupal’s views module.

In this post – we’ll show you how to create such views , step by step, and resolve this on your own.
Notice that this solution does not require a use of another modue besides views.

1) Create the views

  • In the administration menu – select Structure > Views > add new view
    (if the views module is not install – please install and enable it)

    user-search02

  • Select any views name (for example: user-list) ,
  • In ‘show’ – choose ‘Users’ – this is the most important part in the creation of this views,
    and should not be neglected!

  • Mark the checkbox to create a page. Select different options like page title, path, item to display per page, use a pager, etc…
  • The preffered display format should be “table”
  • After saving – you should be now be able to see the default display of the new views.
    At this point – you can only see the list of names in a one column table.

    user-search03

    2) Select fields – In this part – we decide which columns our table will display.

  • Select again in the administration menu : structure > views > your view’s name of choice (in this example I used the name ‘user-list’)

    user-search04

  • Near the ‘fields’ title – select ‘Add’.
  • Select any field you want which starts with the title ‘users’
    In this example, I chose those fields:

    – User: Cancel link

    – User: Created date

    – User: Last login

    – User: Roles

    (Descriptions for each field is written below it)

  • After pressing ‘Apply’ the view setup asks for defying options for each field that selected. You can skip It by just choosing Apply for each.
  • After pressing all the ‘Applies’ you should be able to see your new table now in the preview mode.
  • It is possible to change the order of the different columns by choosing ‘rearrane’ near the ‘fields’ section:

    user-search06

    3) Select filters – in this part we add the search options and filters to manage the users table.

  • Near ‘filters’ – select ‘add’:

    user-search08

  • From the list – select “User: Name (raw)” , and hit ‘apply’

    user-search09

  • In operator – choose ‘contains’ – this guarantees the most flexible search results
    (for example – if I seek people with the name “Joshua” but write in the search only “josh” – it will display the results including Joshua).

  • Select the checkbox ‘expose this filter to visitors”
    – This ensures that that the filter won’t work automatically – instead a search can be made with a textfield area that can be filled by you.

  • Hi Apply.
  • You should be able to see now, above the table the text area that allows us to search and filter the results for the column name:

    user-search11

  • Do the same procedure for the ‘email’ and ‘roles’ filter by choosing another filter .
  • Make sure the ‘required’ checkbox is unchecked – so we WON’T ab obligated to search by email if we don’t want to.
  • Now more search/filter options are available above the table:

    user-search12

    THAT’S IT!

  • If you want, you can set the path for this view , under PAGE SETTINGS.
  • Personally, I prefer to to remove from the “User: Active (Yes)” from the filters.

    user-search13

  • Another last wise modification would be to add this new view to the administration menu, under People option.
  • Note that this practice can be done for other data lists, for example – your drupal contents.