Individual Post and Term content restriction settings

Overview

Ultimate Member allows administrators to control post and term access. You can easily customize restrictions for individual posts and terms, specifying access permissions, verification options, and actions for restricted content. Enhance security with 404 error displays and choose actions for users without access. The Individual Post and Term content restriction settings provide the ability to customize access for posts (including pages and other post types) and terms (categories, tags, and other term types).

Enable the Content Restriction tool for specific Post and Term types #

Enable the Content Restriction tool for post types

  1. Navigate to wp-admin > Ultimate Member > Settings > Access > Content Restriction and scroll down to the Enable the "Content Restriction" settings for post types setting.
  2. Activate this feature for a specific post type by checking the checkbox for the post type.

After enabling, the Ultimate Member: Content Restriction tool will be added under the content in the post settings. Refer to the image below for an example, found at wp-admin > Post > Edit.

Enable the Content Restriction tool for taxonomies

  1. Navigate to wp-admin > Ultimate Member > Settings > Access > Content Restriction and scroll down to the Enable the "Content Restriction" settings for taxonomies setting.
  2. Activate this feature for a specific taxonomy by checking the checkbox for the taxonomy.

After enabling, the content restriction settings will be added under the category or term content setting. Refer to the image below for an example, found at wp-admin > Posts > Categories > Edit.


Individual content restriction settings for posts and terms #

Restrict access to this post? / Restrict access to this term and its posts?

This enables the admin to set restriction settings for the individual post or term.

Note: Please note that individual post settings have the highest priority. This means when you've checked the "Restrict access to this post?" checkbox, the settings of the terms of this post are ignored.

Who can access this post? / Who can access this term and its posts?

  • Everyone – Everyone is the default state for post/term which means that everyone who visits your site will see this post. It's data, comments, etc.
  • Logged out users – If you select this option, it means that this post/term will only be visible to visitors (e.g logged out users). When someone logs into your site they will no longer see this post/term.
  • Logged in users – If you select this option, it means that this post/term will only be visible to logged-in users. Visitors and non-members will not see this block content. 
    • Select which roles can access this post/Select which roles can access this term and its posts - If you choose the "Logged in users" option, you'll find the "Select which roles can access this post/Select which roles can access this term and its posts" setting, displaying all roles on your site. To specify which role(s) can view the post or term, simply select the desired roles.

Would you like to display a 404 page for users who do not have access to this page? / Would you like to display a 404 page for users who do not have access to this term on the term's archive page and terms' posts single pages?

Enabling this option is recommended. It hides the archive pages of restricted posts and terms, as well as all posts related to those terms, by excluding them from the WP Query. This is the safest and most effective method to conceal or hide posts and their comments from all requests, RSS feeds, and other site elements. Notably, this setting does not impact the restricted term archive page, as it remains hidden by default when the term is restricted (refer to the 'Restrict access to this term and its posts?' option)

If checked or enabled: When a post or term is restricted, it will not appear in the adjacent post links. If a user attempts to access the restricted post or term via a link it will lead to a 404 error, indicating that the page is not found. See the example below: Another example below illustrates that the blog post titled 'Discovering Hidden Gems in Nature' becomes hidden when added in a page:

If unchecked or disabledThe 'What happens when users without access try to view the post?' or 'What happens when users without access try to view the term's post?' settings become active, allowing you to configure the desired behavior. You can choose to either redirect the user to a specific or custom page or display the Restricted Access Message based on your configuration.

What happens when users without access try to view the post? / What happens when users without access try to view the term's post?

There is the ability to select actions if the post/term isn't removed from the query. Make this action if the post/terms is restricted according to the conditions:

  • Show access restricted message – This option allows visitors to see a restricted message instead of the post content. When you select "Show access restricted message", you will encounter the "Restricted access message type" setting. This setting enables you to choose the type of restricted message, either Global or Custom.
    If you choose the "Custom message" option, you will then see the "Custom restricted access message" setting below, allowing you to type a custom message.

    The example below is configured to display the access restricted message with the global default message:
  • Redirect user – This means visitors will be redirected from the single post page instead of viewing it. When a user attempts to access a restricted post, they will be automatically redirected. After selecting the "Redirect user" option, you'll encounter the "Where should users be redirected to?" setting. Here, you can choose either the "Login page" or opt for a "Custom URL" redirect.
    If the "Custom URL" option is selected, the "Redirect URL" setting will appear below, allowing you to specify the URL where the visitor will be redirected.

    The example below is configured to redirect user to a login page:

Lock content to verified accounts only? #

This additional setting appears if the Verified Users extension is installed. It is possible to show the content only for verified users.

For developers

The content restriction tool may replace the post title, content and excerpt if the restricted post isn't hidden in the query.

  • $post->post_title - is replaced by the "Restricted Access Post Title" setting value.
  • $post->post_content - is replaced by the "Restricted Access Message" setting value. (Custom individual for post or term. Or a global restricted message from wp-admin > Ultimate Member > Settings > Access tab)
  • $post->post_excerpt - is replaced by empty string to avoid displaying restricted content in the archive.

If you need to customize the WP_Post object of the restricted post. Please use the sample from this Gist.