While it is a well known process to search for user profiles from the WordPress Dashboard, you will require a dedicated user profile management plugin to allow that search on the frontend. And what better user profile management plugin to do that than ProfileGrid. ProfileGrid offers you tons of features for creating and managing user profiles in WordPress. One of which is an advanced user search feature. Today, we are going to take a look at this feature in more detail.
However, this is not a beginner level article. To follow along with the steps mentioned below, you need to have ProfileGrid activated on your site and have a few User Groups and Profiles already created. If your website doesn’t have these, we recommend that you go though our official Starter Guide first. And then, have a look at some of the other articles on our Blog.
The User Search Shortcode
To setup the user search feature on the frontend, you need to have this shortcode added to a page – [PM_Search]
Conveniently, you get a page already created with this shortcode when ProfileGrid is activated on your site. Unless you delete this page manually, there shouldn’t be any need to create a new page with the shortcode again.
The permalink of this search page created by ProfileGrid is profilegrid-search. So if your site URL is https://www.mysite.com, then this page will be accessible on https://www.mysite.com/profilegrid-search.
When viewing the search page on the frontend, you’ll see the basic search option. This has a text box to enter in a text by which it’ll search the users. This is followed by a ‘RESET’ button and an ‘ADVANCE’ button. After the buttons, there is the list of User Profiles which are filtered according to the search parameters.
If no text is added to the search text box, you’ll see all the User Profiles listed here. Also, you can click on the ‘RESET’ button to clear all text from the search text box.
With the advance search, things get a lot more interesting. Advanced search options are visible once you click on the ‘ADVANCE’ button that is next to the ‘RESET’ button below the search text box. As soon as you click on the ‘ADVANCE’ button, a new search filter will appear below it. This is the filter to select a User Group. When a User Groups is selected in this option, the search function will only work on that User Group.
Here’s an example:
I select the User Group “The Wanderers”. Then I search for the user by name “Shirley”. This will display only the user “Shirley S” and not “Shirley D” as “Shirley S” is a member of the User Group “The Wanderers” while “Shirley D” is not.
Now, this is not where the advance search ends. You can also filter Users based on which Group Fields they have added to their Profiles. A Group Field needs to be added to the Advanced Search options to allow search filter by that field. You can do this by visiting that Group Field’s edit page and enabling the ‘Display in Advance Search’ option in it. Once this is enabled, you will see the Group Field for selection along with the User Group filter option after clicking on the ‘ADVANCE’ button. User search results can now be filtered by their Group Fields as well.
Here’s an example:
I search for the user by name “Paul” and select the Group Field “Miles Travelled” to filter results. This will display only the user “Paul D” and not “Paul M” as “Paul D” has the Group Field “Miles Travelled” added to his User Profile, while it is not added to “Paul M”.