Skip Navigation

[Resolved] conditional display of content based on role of logged in user

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 6 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2701289

Hi is it possable to display conditionaly some content in a template based on the role of a logged in user? Doesnt appear to be an option in the loop editor

Thanks

#2701419

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

what you can do is - you should add a Conditional block And select the option Current User Role and check against your role value. Please check the following Doc:
- https://toolset.com/course-lesson/using-toolset-conditional-block/#conditions-based-on-user-roles

Here is more advanced usage of conditional block:
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/

#2701420

Oh sorry i should have mentioned im not using the block editor-

Std original style views

#2701421

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To conditionally display content based on a current user's role, you can use conditional display shortcode [wpv-conditional]:

For Example:

[wpv-conditional if="( '[wpv-current-user info="role"]' eq 'administrator' )"]
 if current user role is administrator - display this content 
[/wpv-conditional]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/
- https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-current-user