How to display, search and filter WordPress user meta data

In this tutorial I’m going to show you how you can use the Users Insights plugin to display, search and filter the data saved as custom WordPress user meta fields.

The WordPress user meta API allows you to store custom data for each WordPress user. Many plugins use the WordPress user meta to store additional information for the users that WordPress doesn’t store by default. Sometimes you might also need to store custom user data, such as registration forms data and the WordPress user meta is perfect for this job.

However WordPress doesn’t provide an option to display the user meta data, which makes it difficult to retrieve the information that has been stored. This is where the Users Insights plugin can come in very useful.

For this purpose you can use the Custom User Fields feature of Users Insights. With this feature you can easily create custom user fields that you can update from the user profile section, as well as display and filter in the WordPress user table.

The Custom User Fields feature works with the WordPress User Meta API, which means that it stores the data as user meta and it can also retrieve any existing user meta.

In order to load your custom user meta data on the user table, simply register a custom user field with the same meta key as your user meta field.


Let’s say, for example, that you want to store the “Job Title” for each WordPress user. You might be using a plugin to store the user meta or just store it by yourself by using the add_user_meta() and/or the update_user_meta() WordPress functions:

<?php add_user_meta( $user_id, 'job_title', $job_title, true ); ?>


In order to retrieve the data saved as “job_title” user meta, all you need to do is register a custom user field with the “job_title” key. You can do this from the Users Insights -> Custom Fields section:


Create WordPress custom user meta field


In this example we set the field type as “Text”, as the Job Title is a text field type. This means that Users Insights will provide text-based filters in the WordPress user table, such as “contains” or “starts with”.

Once the field is created it will be available in the fields section of the Users Insights page. You can make the “Job Title” field visible on the table by clicking on the “Eye icon” and checking the “Job Title” option.


Display WordPress custom user meta field


Once visible, you can review all the stored data for this field on the table:

List WordPress user meta field data

You can also sort your table based on this field data (alphabetically):

Sort WordPress user meta data

One of the most useful features is that you can filter your WordPress user list by the custom user meta data, so you can easily search for users that have a specific value selected for this field. Here is an example where we search for all users, whose job title is any kind of designer:

Search WordPress user meta data

If you want to learn more about the Users Insights Filters, you can visit the Smart Filters page that describes this feature in detail.

Besides the user table, Users Insights also displays the custom user meta fields in the user profile section. In this section you can view all the existing user meta, as well as edit the custom meta fields data:


WordPress edit user meta data


In addition to the standard text field types, Users Insights also provides a number field type, that can be used with any user meta that stores numeric data.

If, for example, you store your users age as user meta with a meta key “age”, you can just create a custom user field with the “age” key and select the “Number” field type.


Create WordPress custom user meta number field


Once created, just like the example above, you can display the data stored for this field, as well as sort and filter the user table by this field ‘s data. For the numeric field types you can use filters like “is bigger” or “is smaller” to find the users that fulfil a certain criteria.

Filter search WordPress user meta

Another field type that Users Insights supports is a date field type. This field type is read-only, which means that it can be primarily used to retrieve existing user meta data, stored in a date format. When a custom user meta field is registered as a date field, you will be able to sort the user table by this field in a chronological order.

Additionally, you can use date operators in the filters to search the user meta fields by various criteria. For example, you can use filters like “is more/less than x days ago” or “is before/after x date”. The filters provide an interactive date picker that can be used to easily apply a date condition.

Here is an example where we have applied a filter to our custom date field to find all the users that were born after a selected date, with the user table sorted by this field in an ascending order.

Search WordPress user meta by date field


If you don’t know the meta keys used

If you are not sure about what meta keys are used to store your custom user meta, you can use the Extended CRM For Users Insights plugin. This is a free add-on that provides some extended features for Users Insights.

One of the features that it provides is listing all the existing user meta keys in the Custom Fields section. With this option you can find the meta keys that your scripts/plugins use to store the data and select them from the list when creating a custom field.


List existing WordPress user meta keys


Exporting the WordPress user meta data

With the Users Insights Export feature you can also export your WordPress user meta data in a CSV format. The export feature allows you to export the data with the same settings applied to the user table, including all the filters applied, visible fields selected and sorting options. This allows you to create a fully customized user export.

With the example above, where we have applied a filter to find all the users that are older than 30, in order to export the data generated on the table, we just need to click on the Export button. This will generate a CSV file with the same exact data:


Export WordPress user meta data



Whether you use a plugin or a custom script to store custom WordPress user meta, at some point you would need to review this data. Users Insights gives you the tools to display, search and filter your existing user meta data, so you can easily analyze and make sense of your user data.