Back to contents

JetEngine: How to Hide Content if the User Doesn’t Renew a Subscription

 

This tutorial teaches you how to make widgets, columns, and sections visible/invisible if the user pays for the subscription or the subscription is expired using the JetEngine Dynamic Visibility module.

JetEngine is a WordPress plugin, which provides the user with all the needed tools for displaying dynamic content in Elementor and Gutenberg. With the JetEngine plugin, you can create a membership site with a whole set of features. The Dynamic Visibility module is one of them, and it allows you to define parameters of visibility for every element on the page.

With the Dynamic Visibility module, you can show the unique content or hide the advertisement for the users with the unexpired subscription.

At first, you need to add a meta field to the user. You can do this by creating a Meta Box.

Proceed to JetEngine > Meta Boxes and click on the “Add New” button.

jetengine meta boxes list

Give Meta Box a Title and select the Meta Box for “User” option in the General Settings section. Then choose the Visible at “Edit User” option in the Visibility Conditions section; this feature lets you add meta fields only on the Edit User page, and only the administrator can see and edit it. If you want to know more about the Meta Box Visibility Conditions, proceed to this dedicated overview.

meta box general settings and visibility conditions

Create the Meta Field for the expiration date. Hit the “New Meta Field” button in the Meta fields section. Enter the meta field Label and click on the Name/ID field to generate the slug automatically. If you want to change it, keep in mind that the ID shouldn’t include spaces and make sure it consists only of the letters and numbers. Also, be aware that ID should be unique and shouldn’t coincide with the other meta fields’ IDs.

Leave the “Field” option in the Object Type selector and choose the “Date” option in the Field Type. Enable the Save as timestamp toggle.

meta box expiration date meta field

Lastly, push the “Add Meta Box” or the “Update Meta Box” button.

Next, navigate to the Users tab in the WordPress Dashboard and hit the “Edit” button under the needed user.

users wordpress dashboard

Proceed to the end of the Edit User page and enter the expiration date of the user’s subscription. Press the “Update User” button.

edit user page

Go to any post or page and click “Edit with Elementor.” Select any of the elements on the page and go to Advanced > Dynamic Visibility. Enable the toggle.

Select the “Show element if condition met” option in the Visibility condition type drop-down and choose “Greater than” in the Condition selector. Hit the Dynamic Tagsbutton in the Field and select “User Field.” Click on the chosen dynamic tag in the Field, and you will see the window with settings. Select the meta field with the user’s subscription expiration date.

dynamic visibility user field dynamic tag

Choose the “Current User (global)” in the Context field.

context current user global

Hit the “Dynamic Tags” button in the Value field and select the JetEngine “Macros” dynamic tag.

jetengine macros

Select the “Today” macro from the list in the Macros field.

jetengine macro today

Pick the “Numeric” in the Data Type field.

data type numeric dynamic visibility

Then, click on the “+ ADD ITEM” button to add a new “User logged in” Condition.

dynamic visibility condition user logged in

And now, the widget is visible on the front end after all settings. It is hidden for the users with the empty meta field or the expired subscription, and it’s shown for the users whose expiration date has not reached today’s date.

dynamic visibility showing content on the front end

That’s it. You know now how to show content for the user with the unexpired subscription.