How to create more advanced WordPress user searches

In this article, we will see how to go beyond the default WordPress user search. We will see how to use some Users Insights features to create more advanced user searches. WordPress user search is the process of looking for specific users within a WordPress website or content management system. This search can be performed based on various criteria, including usernames, email addresses, user roles, custom user attributes, or any other relevant information associated with user profiles. The purpose of WordPress user search is to efficiently locate and manage users within the WordPress platform, which can be especially useful for administrators and site owners when handling user accounts, permissions, and interactions on the website.

When running a WordPress site, we often need to find a specific user or group of users. Usually, what we’d do is use the Users section of the WordPress dashboard. WordPress has a built-in search functionality that provides a way to search users by some parameters. But, as you might have noticed, the default user search functionality of WordPress is somehow limited. It only allows you to search users by a few different parameters like their username (nice name), name, and their email. But what if you need to search users by different parameters like: user role, user profile data, custom field, post type, or some other custom search term?

The default WordPress user search functionality is somehow limited. It only allows you to search users by a few different parameters like their username (nice name), name, and their email.

Users Insights extends the default WordPress user search functionality and provides a number of additional features and filters. This creates a better search tool that allows you to perform more advanced and precise searches of your WordPress user list. There are many different filters and searches that you can achieve with the help of the Users Insights smart filters, but in this article, we are only going to focus on the ones that are related to the default WordPress user profile data like first name, last name, date registered, email, etc. If you want to learn more about the other ways you can search and filter your WordPress users with Users Insights, be sure to check the Features and Integrations

wordpress search users

 

Searching WordPress users by their first and last name

When creating a new WordPress user, you have the first and last name fields by default. They can be used in many ways by theme authors, and one of the most common ways is using them to identify comment authors.

But when using Users Insights, you can search through both First Name and Last Name fields separately or combined. So, when you use a regular WordPress search form, you can’t specify where you are searching.

On the other hand, when using Users insights, you can select if your search query will apply to first name, last name, or even both. Let’s say you want to get all the Lee’s from your user base; you can do that by simply searching Lee as the display name.

search wordpress users by name

But if you want to check just Lee as a last name, you can do that as well:

search wordpress users by last name

Now you can see that we’re using the “contains” filter. You have other options as well depending on how you want to filter out your users. Here are the different variations for your search criteria:

  • Contains
  • Does not contain
  • Is
  • Is not
  • Starts with
  • Ends with
  • Is set
  • Is not set

You can see that each set of search criteria has its opposite. It just means that every time you are searching and get some results, searching for the opposite is going to hide all the current results, and show all users previously hidden.

Let’s have a look at each of these with some examples.

The contains filter is a broader view. It will return search results of all users that have this string, no matter where it appears in the selected field. For example, if we type “El” here are our results:

search wordpress users last name contains

So we’ll get GabriEL, LouELla, EthEL and so on. The opposite (does not contain) will just reverse this logic, so any names that contain this string are going to be removed.

As for the “IS” filter, it’ll look for an exact match. Thus, if you know the user’s last name, for example, you can use it to filter them:

search wordpress user last name is

Should we search for a slight variation and we simply wouldn’t get this result. The “Is not” operator works in the same way, but removing the results that match our search text.

Regarding the “Starts with” and “Ends with” operators, they do exactly what it looks like. They’ll search our string in the beginning or end of our fields. Thus, if you want to export your users alphabetically, you can search for users whose name starts with “a”, then “b” and so on, exporting on each step:

WordPres export users alphabetically

The “is set” filter works in a little different way. Instead of allowing you to search for a specific name, it will show all the users who have any kind of value in the WordPress database set as their first name or last name fields in their WordPress profiles. The “is not set” field is particularly useful if you want to find all the WordPress users who have not entered their first name or last name on their WordPress profile page.

 

Searching WordPress users by email

The default WordPress user search functionality lets you search your users by email. But this feature can’t be combined with other search methods, and these can’t be exported. The Users Insights filters enable you to create more advanced WordPress user searches based on their email address.

If you click on the “Add Filter” button and select the email filter, you will notice that there are several different options from which you can choose. Similarly to the name search operators, each of them is going to be useful for specific scenarios.

The first option is the “contains” filter, which, as the name suggests, allows you to perform a more broad search of your users’ email addresses.

There are many cases when this can be a useful filter; for example, if you want to find all the users that work in a specific company domain but not limited to a country. So you could search for “@pepsi,” and this will show you all users with emails from pepsi.com, pepsi.co.uk, pepsi.com.au, pepsi.com.br, and so on.

users with email from pepsi

Next, let’s see the “does not contain” filter. It works in a similar way, but it shows you search results that don’t contain the search phrase. This filter can be useful if you want to exclude a particular phrase or email domain from your user list, for example, to exclude free email providers such as Hotmail, Yahoo, and so on.

Users not from popular email platforms

In addition, the “is” and the “is not” filters will show you only users whose email address matches or doesn’t match that specific search term. That’s useful when you know the user’s email (or just got an email from them) and want to know more about them.

As for the “starts with” and the “ends with” filters, in a similar way, they allow you to perform searches of your users by using the beginning and the end of their email addresses. The “starts with” filter can be used to gather all users with some common email names, such as admin, hello, contact, and so on:

users email start with

Regarding the “ends with”, it could be used to get all emails from an exact domain, such as pepsi.com.

emails ending with pepsi.com

 

Searching WordPress users by user role

The WordPress user page allows you to filter your users based on their role. Clicking on the role name at the top of the user list will show you all the users that have that specific role assigned. In a similar way, Users Insights also enables you to list all the users that have a specific role, just by using the “Role is” filter.

Users Insights however, also provides another role filter that you might find useful when when it comes to searching your WordPress users by their role. The “Role is not” filter allows you to show all the users who don’t have a specific role assigned. For example, if you want to see all the users that are not admins, you can just apply a filter “Role is not Admin”:

role is not filter

 

Searching WordPress users by username

The username filter of Users Insights works in a similar way as the name filters that we already discussed. This means that you can perform similar searches of your WordPress users by their username. For example, you can use the “contains” filter for more broad user searches and the “is” and “is not” for more specific searches. The filters “starts with” and “ends with” are also available.

username starting with red

 

Searching WordPress users by custom fields

Before you can search users by custom fields, you need to ensure that you have custom fields set up for your users. Users Insights should be able to detect and display these custom fields in the user profile table automatically. If your custom fields are not showing, make sure they are correctly added to your user profiles.

You can register custom usermeta fields in the Custom Fields section of Users Insights:

 

All custom user meta fields can be readily accessed within the Users Insights filters, enabling effortless filtering of your WordPress user base based on these fields. The filter system automatically identifies the field type and offers corresponding conditions. For instance, text fields come with options such as “contains” and “starts with,” while number fields feature conditions like “is bigger than” and “is smaller than.

 

Here is an example of showing all the users with age greater than 30:

Here is another illustration of creating advanced search of WordPress users based on their occupation. In this case, our objective is to identify all users whose profession is connected to marketing.

 

 

Searching and sorting users by date registered

If you have ever been in need to find the most recently registered users in WordPress, you have probably noticed that there isn’t a way to do this with the default WordPress functionality. The user list in the WordPress dashboard is ordered alphabetically, and there isn’t a Date Registered column in the user table. This information is only available in the user profile section, and there isn’t a way to sort your users by date registered.

The Users Insights plugin makes the date registered field available in the Users Insights user table, as well as in the smart filters. Therefore, if you want to find your most recently registered users, all you need to do is click on the date registered column title. In this way, the user list will get ordered by this field, showing you the most recently registered users at the top of your user list.

user's ordered by registered date

Since this information is also available in the filters, you can use it to apply custom filters based on the date the user has registered. Here is an example showing all the users that have registered in the last 30 days:

Users registered more than 30 days ago

There are multiple filters that you can apply for the date registered field:

  • Less than [number of days]
  • More than [number of days]
  • Exactly [on a date]
  • After [date]
  • On [date]
  • Before [date]

 

Conclusion

WordPress user management is one of the most important things to do when planning to create a solid and reliable website using WordPress as a platform. In this article, we have shown you how to manage your users with some advanced features of the Users Insights WordPress plugin. We explored how using Users Insights as an internal search plugin can improve your user experience and search results. We saw the different internal search criteria you can use with the search plugin and when they can be helpful for you. In case you are using custom user meta fields, make sure to check the How to display, search, and filter WordPress user metadata, as well as check the other Users Insights integrations and features for more info.

We hope that this article was useful and that it will help you with the user management and organization of your WordPress website.