Restrict for Elementor

Show/Hide Elementor Content to Users with a Specific Meta Value

Want to show or hide Elementor content based on user meta values? With Restrict for Elementor you can control the visibility of any Elementor section, column or widget by comparing a meta key stored in a user’s account against a value you define — complete with logical operators like =, !=, >, LIKE or BETWEEN. In this guide, you will learn what user meta is, how each comparison operator works, and how to build a real-world rule such as “show this widget only to customers with three or more WooCommerce orders”.

What is user meta in WordPress?

Each user account in WordPress has a set of meta values stored under specific meta keys. Some of WordPress’ default meta keys are nickname, first_name and last_name, and they store the corresponding data for each user. Beside the default ones, plugins can add their own meta keys. For example, WooCommerce stores the number of orders a user has made under the _order_count meta key.

To see exactly which user meta data exists on your website, open your site’s database (using phpMyAdmin, Adminer or a similar tool), load the wp_usermeta table (assuming the default “wp_” table prefix) and search for a user by their ID. You will see all the meta keys and values stored for that user.

wp_usermeta database table showing user meta keys and values in phpMyAdmin

Example table – this might look different depending on which database management tool you’re using.

Because plugins constantly write useful data to user meta, this becomes a remarkably flexible restriction criterion: purchase counts, membership fields, profile data, custom onboarding flags — anything stored per user can drive what that user sees on a page built with Elementor.

Setting up the Meta Key

The Meta Key is the first field you need to fill in. Enter the key exactly as it is written in your database — a typo or different capitalization will not match anything. When in doubt, copy the key directly from the wp_usermeta table.

Once you enter the meta key, three new fields appear: Meta Compare, Data Type and Meta Value.

Meta Compare: the comparison operators

Meta Compare is the logical operator used to compare the user’s stored meta value with the value you enter in the Meta Value field:

  • = – the meta value is equal to the value you entered
  • != – the meta value is not equal to the value you entered
  • > – the meta value is larger than the value you entered
  • >= – the meta value is equal to or larger than the value you entered
  • < – the meta value is lower than the value you entered
  • <= – the meta value is equal to or lower than the value you entered
  • LIKE – the meta value is similar to the value you entered — e.g. if you enter “John”, similar values are accepted (“Johnson”, “Johndoe”, “Johna”, …)
  • NOT LIKE – the meta value is different from the value you entered — e.g. if you enter “John”, all values that do not contain “John” are accepted (“Smith”, “Wilson”, “Doe”, …)
  • IN – the meta value is within the list you entered — e.g. entering “John, Steven, Lucy, Amber” accepts only those values
  • NOT IN – the meta value is not within the specified list — e.g. entering “John, Steven, Lucy, Amber” accepts every value except those
  • BETWEEN – the value is between the start and end values you entered, separated by a comma — e.g. 10,15 accepts 11, 12, 13 and 14
  • NOT BETWEEN – the value is not between the start and end values (separated by a comma) — e.g. 10,15 accepts everything except 11, 12, 13 and 14
  • EXISTS – checks whether the entered meta key exists for that user and shows/hides the content if it does
  • NOT EXISTS – checks whether the entered meta key exists for that user and shows/hides the content if it doesn’t

Meta Compare dropdown in Restrict for Elementor listing all comparison operators

Data Type: matching how the value is stored

In the Data Type dropdown, select the type of the meta value you’re working with so the comparison is performed correctly:

  • NUMERIC – meta values stored as numeric values
  • CHAR – meta values stored as character strings
  • DATE – meta values stored as a date
  • DATETIME – meta values stored as date and time
  • DECIMAL – meta values stored as decimal values
  • TIME – meta values stored as a time value

Data Type dropdown in Restrict for Elementor with NUMERIC, CHAR, DATE and other options

Real-world example: reward repeat WooCommerce customers

All of this may sound a bit advanced, so let’s put it into perspective with an example. Say you want to show an Elementor text widget only to users who have made three or more WooCommerce orders on your website — for instance, a loyalty discount code.

  1. Enter _order_count in the Meta Key field
  2. Select the >= operator from the Meta Compare dropdown
  3. Select NUMERIC from the Data Type dropdown
  4. Enter 3 as the Meta Value

Restrict for Elementor settings showing _order_count meta key with >= operator and value 3″ width=”292″ height=”421″ /></p>
<p>This tells Elementor to display the widget only if the logged-in user has the number 3 or larger stored under the <code>_order_count</code> meta key in their account. If the condition is true, the widget is shown to that user; everyone else simply won’t see it.</p>
<h2>Show alternative content instead</h2>
<p>If a user does not fulfill the criteria, you don’t have to leave the space empty — you can display alternative content to them instead, such as a sign-up prompt or a teaser. Learn how in our <a href=alternative content documentation.

Related documentation