Help Center

Query Builder Users Query Type

This overview describes all the Query Builder’s Users Query Type settings, which are a part of the JetEngine plugin.

With the “Users” Query Type, available as a part of the JetEngine’s Query Builder, a custom query for retrieving WordPress users can be created, allowing only those users who meet the set conditions to be displayed in a Listing template.

The query settings can be found in the WordPress Dashboard > JetEngine > Query Builder directory. To build a new query, one should press the “Add New” button.

Initially, the General Settings section is presented, which is common for all queries. Here, the following settings are available:

users query general settings
  • Name — the name given to the query and displayed in the Query Builder menu;
  • Description — a short description of the query that helps navigating among the query list;
  • Query Type — a type of built query. Here, the “Users Query” option should be selected now;
  • Custom Query ID — the field that should be completed if needed to work with JetSmartFilters; it is optional. One can specify the ID here and add the same value to the built filter;
  • Cache Query — a toggle that is activated by default. It enables caching of the current query. It can be deactivated if one experiences issues with query results;
  • Cache Expires — a field where one can specify the expiration limit of the cache. By default, the field is empty, and no expiration is applied. This option is only applicable when an external object cache (such as Redis or Memcached) is used. Otherwise, the cache is valid only during a single request;
  • Register Rest API Endpoint — a toggle that is deactivated by default. When activated, the REST API endpoint can be registered. With this endpoint, one can adjust the public access to this query’s results and allow the retrieval of data. More information can be found in the Register Rest API Endpoint guide. 

User Role

This tab allows one to include or exclude users based on their WordPress user role.

user role tab of the users query
  • Role — a dropdown menu that includes all the user roles on the website. Here, one can select the needed role(s) so that users with such role(s) on the website are included in the query. Mind that every user should match every role picked in this field in order to be queried;
  • Role In — a dropdown field that also allows selecting the user roles. But this time, the users who are assigned to at least one of the roles chosen will be added to the list;
  • Role Not In — a dropdown field that also allows selecting the user roles.  The users assigned to at least one of the roles chosen here will be excluded from the list.

Include/Exclude

Here, one can also include or exclude users. This time, it can be done by specifying the user ID.

include or exclude tab of the users query
  • Include — a field for the IDs of users that should be added to the list;
  • Exclude —  a field for the IDs of users that should be excluded from the list.

Misc

In this tab, the additional customization fields are presented:

misc tab of the users query
  • Search — a field that allows displaying only users having a specific value in one of their default meta fields (like “Login,” “Email,” or “URL”). Afterward, one should choose the default meta field in the Search Columns drop-down menu. The typed-in value will be searched in the fields selected in the Search Columns list. Only users with that value in the chosen fields will be added to the list. One can also set the search rules here (in the Search field) using the “*” symbol:
    • “*” before the value — the system will search the values that start with the symbols typed. For example, if the “*a” value is inserted into the bar, all the users that have a value that begins with “a” in the selected field will be added to the list;
    • “*” after the value — the system will search the values that end with the symbols typed. For example, if the “a*” value is inserted into the bar, all the users that have a value that ends with “a” in the selected field will be added to the list;
    • “*” before and after the value — the system will search the values that contain symbols typed. For example, if the“*a*” value is inserted into the bar, all the users that have a value that includes “a” in the selected field will be added to the list;
  • Search Columns — a dropdown menu that contains all the meta fields attached to the users. Here, the meta field in which to search for the value of the Search bar should be selected;
  • Number — a bar where one can define the number of users that will be added to the list;
  • Offset — a field for the number of first posts that won’t be added to the list;
  • Paged — a feature that works like there’s pagination added to the list. One can type a number of the page, and all the users that would’ve been shown on that page will be added to the list;
  • Order By — a field that allows selecting by what value to order the users in the list;
  • Order —  a field that allows selecting how the users will be ordered, from lowest to highest values or vice versa.

Meta Query

This tab allows adding users to the list based on the values of their meta fields. One sets a value in the Value text area, and then the data from the meta field selected in the Field key/name bar is compared to that value. If they match, the user is added to the list. The conditions the value of the meta field has to meet are called the Meta Query Clause

One can add as many Meta Clauses as needed by clicking on the “Add New” button.

meta query tab of the users query
  • Field key/name — a field for the name of the meta field attached to the users. In this bar, the dynamic tags feature can be used as well. For instance, we select the “Current terms” macro and press the “Advanced settings” button to set the “Queried User” Context and fill in the Fallback field with the desired value (e.g., “Not Found”). So now, the queried posts will be displayed for only the queried user. And once the posts are absent, the fallback “Not Found” will be shown. The Context and Fallback can be set for any selected macro;
  • Compare — here, one can select how the values will be compared:
    • Equal — displays posts having an equal value;
    • Not Equal — shows posts that don’t have an equal value;
    • Greater than — shows posts that have a greater value. It works with numeric values only;
    • Greater or equal — displays posts that have a greater or equal value. It also works only for numeric values;
    • Less than — shows posts that have a lesser value. For numeric values only;
    • Less or equal — displays posts that have a lesser or equal numeric value;
    • Like — shows posts that have the value set in the Value field mentioned in the content;
    • Not like — displays only the posts that don’t have the value put in the Value field mentioned in the content;
    • In the list — after several values to the Value field are added, it shows the posts that have at least one of them in their content;
    • Not in the list — displays posts that have any values except the ones typed into the Value field;
    • Between — displays posts that contain the value between two, which are set in the Value field; 
    • Not between — shows all the posts except the ones that have a value that matches the set interval;
    • Exist — shows all the posts that contain the Key. There is no need to set the Value in this case;
    • Not exist — displays all the posts that don’t include the Key. There is no need to select the Value either;
    • Regexp — queries users depending on the checkboxes or radio meta field values;
    • Not regexp — excludes the mentioned checkboxes or radio value, the query will not take it into account;
  • Value — the value set here will be compared to the value of the meta field selected in the Field key/name bar.
Things to know

If the “Query Variable” option is selected in the Value field, the “Exclude this clause from the query if dynamic value is empty” checkbox appears below the Value field. It can be checked to remove an argument from the query if its macro returns an empty value. However, when this feature is activated, the Fallback field in the Advanced Settings of the “Query Variable” option should be left empty.

  • Type — this drop-down allows one to specify what kind of data is stored in the chosen meta field:
    • Char — alphabetic data that is not sensitive to case;
    • Numeric — whole numbers only;
    • Date — date values (be aware, the Save as timestamp toggle should be enabled in the fields from which the date values are taken);
    • Datetime — date and time (be aware, the Save as timestamp toggle should be activated in the fields from which the date values are taken);
    • Decimal — fraction number data;
    • Time — time values;
    • Binary — data that is sensitive to the case;
    • Signed — whole numbers, both positive and negative;
    • Unsigned — whole numbers, only positive.

Also, if one needs to create more complex meta query clauses, the new meta query group can be added by pressing the “Add new group” button.

When clicked, one can set the Relation, “And” or “Or.”

To edit the group clause, the “Edit group clauses” button should be clicked.

edit group clauses button

In the opened pop-up, one can customize the same fields as in the Meta Query tab earlier to build the needed group clause.

The “Add new clause” button should be pressed each time a new clause needs to be created.

edit group clauses pop-up

More information about creating group clauses can be found in the How to Create Group Clauses for Query Arguments tutorial.

Date Query

This tab should be adjusted to query users depending on the date criteria.

date query tab of the users query
  • Year — users that were created or modified this year will be added to the list;
  • Month — users that were created or modified this month will be added to the list;
  • Day — users that were created or modified on this day will be added to the list;
  • After — users created or modified after the date entered into this bar will be added to the list;
  • Before — all users created or modified before the mentioned date will be added to the list;
  • Inclusive — a toggle deactivated by default. If one enables this toggle, the date typed in the After or Before bars will be included in the range;
  • Compare — a dropdown menu where one can choose how the date added to the Year, Month, and Day bars will be compared to the date of user creation or modification;
  • Column —  a dropdown menu where one can choose which date to take, the date of creation or modification.

In this tab, one can set the query depending on the location. The query will select users with the coordinates of points within this radius stored in the corresponding fields. The received data does not have to be displayed on the map; it can also be done using a listing.

Beginning with the corresponding tab, here, the map under the Select location field is displayed. One should pick the desired point on the map to set it as the center for the search.

Warning

The map is displayed depending on the provider selected earlier in the Map Provider settings.

Then one should work on the further setting fields presented after the map:

geo search tab of the users query
  • Address Field — a field where an address meta field value built beforehand with JetEngine should be put. It can be the meta field of the user that stores the address. It can be either a “Map” meta field or two meta fields values that keep latitude and longitude separated by a comma;
  • Distance — a field to type in the radius to conduct the search around the picked center;
  • Units — a field where one can choose between the “Miles” and “Kilometers” to set the desired distance unit.

Once the needed fields in the described tabs are adjusted, one can press the “Add Query” button to publish the query.

That is all about the “Users” Query Type available as a part of the JetEngine plugin’s Query Builder for WordPress websites.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 30K+ Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.