Restrict content on a page/post to specific users community role

With Ultimate Member, it is possible to exercise complete control over the visibility of content for specific user community roles. This is accomplished by encapsulating the content with the shortcode provided below:

[um_show_content roles="member"] This text can only be seen by users who have role "member" [/um_show_content]

It is essential to note that this feature offers a comprehensive solution for managing user community roles. The shortcode can be used to restrict access to specific content, making it invisible to certain user groups. This functionality provides an effective way to manage user permissions and ensure that only authorized individuals have access to sensitive information.

Ensure that the Role ID is utilized in the roles and not attributes for optimal performance. The Role ID is located in the Ultimate Member User Roles table, which can be found in the wp-admin>Ultimate Member> User Roles> Role ID.

Show content to specific roles

[um_show_content roles="member"] <!-- insert content here --> [/um_show_content]

To add multiple target roles, simply separate each role with a comma ' ,'.

[um_show_content roles="subscriber,um_moderator,um_content-creator"] <!-- insert content here --> [/um_show_content]

Example:

It's possible to restrict access to certain content based on the user role by adding the role IDs in the shortcode. This means that only users whose role IDs are INCLUDED in the shortcode will be able to view the content. The purpose of this feature is to ensure that the content is visible only to a specific group of users with particular roles, as defined by the shortcode. Therefore, it's crucial to select the appropriate role IDs while using the shortcode to control access to the content.

Hide content from specific roles

[um_show_content not="member"] <!-- insert content here --> [/um_show_content]

To add multiple target roles, simply separate each role with a comma ' ,'.

[um_show_content not="subscriber,member"] <!-- insert content here --> [/um_show_content]

Example:

The shortcode allows admins to restrict access to content by specifying the user role IDs. Content covered by the shortcode will be hidden or inaccessible to the specified user roles, allowing only NON-INCLUDED role IDs in the shortcode to view it. It's important to choose the correct IDs to regulate access.

Adding tags to text

Common placeholders (tags) can be used inside the shortcode. The shortcode then converts these to their proper values.

[um_show_content roles="contributor,subscriber"] {display_name} [/um_show_content]

What the specific roles see:

The content that is restricted on the page/post is hidden from other community roles. They won't see any indication that there is content they cannot access.