Navigation überspringen

[Gelöst] conditional display of content based on role of logged in user

This support ticket is created vor 1 year, 11 months. There's a good chance that you are reading advice that it now obsolete.

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 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 1 year, 11 months.

Assistiert von: Minesh.

Author
Artikel
#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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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