Skip to content

How to Protect Content Based on User Role in Elementor Website?

Table Of Content

Some content should only be for people who are already logged in — a price list for customers, notes for editors, a download for subscribers.

The Protected Content widget in The Plus Addons for Elementor can gate a section on the visitor’s WordPress user role, with no password involved.

To check the complete feature overview documentation of The Plus Addons for Elementor Protected Content widget, click here.

Requirement – This widget is a part of The Plus Addons for Elementor Pro, make sure it’s installed & activated to enjoy all its powers.

Before You Start

  • Edition: Pro — Protected Content is only in The Plus Addons for Elementor Pro. With the Pro plugin switched off the widget is not in the editor at all, and a page that already uses it shows nothing where the widget was — not the gate and not the protected content either.
  • Widget to enable: Protected Content, switched on under The Plus Addons > Widgets. Search for the widget name there and turn its toggle on.
  • You need the roles to exist: the Select Roles list is built from the roles registered on your site, so plugins that add roles (WooCommerce adds Customer, for example) add them here too.
  • Test while logged out: use a private window. Logged in as an administrator you are not a good test of what a visitor sees.

Set the Role Gate

  1. Add the Protected Content widget to the page.
  2. In the Content section, put the content you want to protect in Protected Content (or switch Content Source to Page Template and pick a template).
  3. Open the Protection Type section and set Protection Type to User role.
  4. In Select Roles, pick one or more roles. The field accepts several.
  5. In the Message section, write what everyone else should see — say plainly who the content is for and how to get access.
Protection type set to user role, with customer chosen in select roles

Choosing User role removes the password form completely. The Form Text and Error Message sections have no effect on this protection type.

What Each Visitor Sees

With Select Roles set to Customer, this is what three different visitors got on the same published page.

VisitorWhat they seeIs the content in the page source?
Not logged inThe message onlyNo
Logged in, role SubscriberThe message onlyNo
Logged in, role CustomerThe protected contentYes
A logged-out visitor sees only the message explaining who the content is for
The same section seen by a visitor logged in with the customer role, showing the protected content

Because the message is the only thing most visitors will ever read, it is worth designing. Switch Message Source to Elementor Templates if you want a full section there instead of a line of text.

A page section locked to the customer user role

How It Behaves

  • The check happens on the server while the page is built. For anyone without a matching role the protected content is never written into the HTML.
  • The widget looks at the visitor’s first role. A user who holds several roles may not match, even if one of the roles they hold is in your list.
  • Administrators are not automatically let through. If you want to see the content yourself, add your own role to Select Roles.
  • Leaving Select Roles empty locks everybody out — everyone gets the message.

Limitations

  • There is no login form in the widget. A logged-out visitor sees your message and has to find their own way to a login page, so put a link in the message.
  • Role gating protects this widget’s content, not the page. The page URL still works for everyone and the rest of the page is public.
  • Preview of Error Message, in the same section, does not only affect the editor. Switch it on and visitors who are allowed see the message printed under the content as well. Leave it on Hide for published pages.
  • Multi-role users are matched on their first role only, as described above.

Troubleshooting

A user with the right role still sees the message

Check whether that user holds more than one role. Only the first one is compared. Give the user just the role you are gating on, or add their other role to Select Roles as well.

The message appears under the content for allowed users

Set Preview of Error Message back to Hide in the Protection Type section.

The editor shows the content, the live page does not

You are logged in as an administrator in the editor. Open the published page in a private window to see what a visitor gets.

Related Docs

Related Frequently Asked Questions

Related Docs