Restrict content on a page/post to logged in users
With Ultimate Member you can make certain content on a page/post only viewable to logged-in users. To do this you need to wrap the content in the following shortcodes:
[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:
- 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
- The restricted content on the page/post is hidden and logged out users see nothing on the page/post to indicate that there is the 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:
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="You are not logged in"] 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 the ways in which 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 in the shortcode above it has the tag {first_name}
which will display the first name of the logged-in user who is viewing the page/post where the shortcode has been added.
Tags
- {first_name}
- {last_name}
- {username}
- {nickname}
Custom meta keys
As well as using the pre-defined tags you can also 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] Hello, you are currently living in {usermeta:country} [/um_loggedin]
As well as using the pre-defined tags you can also 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}