Restrict content on a page/post to logged in users

Ultimate Member provides you with the ability to restrict access to certain content on a page or post exclusively to logged-in users. This can be achieved by using shortcodes to enclose the content.

[um_loggedin] This text can only be seen by logged-in users [/um_loggedin]

What logged-out users see

When using the logged-in user on-page content restriction there are two options to decide from for what logged-out users see:

Option 1: Logged-out users see a text box letting them know there is content on the page/post that they do not have permission to view

Option 2: The restricted content on the page/post is hidden and logged-out users see nothing on the page/post to indicate that there is content they cannot see

Option 1

If you wish to use option 1 and let logged-out users know there is content on the page they do not have permission to view then you can use the following shortcode:

[um_loggedin show_lock="yes"] This text can only be seen by logged-in users [/um_loggedin]

The output on the page for option 1 is for logged-out users:

The output on the page for option 1 is for  logged-in users:

If you wish to customize the text that is shown to logged-out users in the text box you can add custom text to the shortcode like so:

[um_loggedin show_lock="yes" lock_text="Explore this exclusive content by signing in or becoming a member."] This text can only be seen by logged-in users [/um_loggedin]

Option 2

If you wish to use option 2 so that logged-out users do not see that there is restricted content on the page then you can use the following shortcode:

[um_loggedin show_lock="no"] This text can only be seen by logged-in users [/um_loggedin]

Adding tags to text

One of how you can use the logged-in content restriction is to personalize your site. For example, you may want to have text on a specific page that says "Welcome back John, here is what has been happening recently". To create something like this you would use the following shortcode:

[um_loggedin] Welcome back {first_name}, here is what has been happening recently [/um_loggedin]

As you can see in the shortcode above it has the tag {first_name} which will display the first name of the logged-in user viewing the page/post where the shortcode has been added. See the image below:

Tags
  • {first_name}
  • {last_name}
  • {username}
  • {nickname}

Custom meta keys

As well as using the pre-defined tags, you can use any meta keys for custom fields you have created. To add a custom meta key to the restricted content you need to add the tag to the restricted content text e.g {usermeta: age}

[um_loggedin] Community Spotlight: WellnessHubCommunity in  {usermeta:country} [/um_loggedin]