Skip Navigation

[Resolved] writing a condition in custom html

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to use conditional block to display the conditional content based on current user role

Solution:
Conditional block allow you to display the conditional content based on the current user role.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/writing-a-condition-in-custom-html/#post-1745101

Relevant Documentation:
=> https://toolset.com/course-lesson/using-toolset-conditional-block/

This support ticket is created 4 years, 4 months ago. 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 -

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

This topic contains 3 replies, has 2 voices.

Last updated by AlimB3245 4 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1744899

Tell us what you are trying to do? I need to use the IF condition as below
IF the current user's role is 'abc' then show the next code..
it's actually a URL that I am creating with multiple variables being sent as hidden link' and so on.. but I need one variable to be displayed only if a condition about the current logged in user is met.. I couldn't find documentation for this on the site.. there was some documentation on how to use the CONDITIONAL block but not how to write it raw.. some guidance would be appreciated.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?hidden link

#1745033

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The thing is that you can add conditional display using two way:
- If you are using Blocks, you can use the conditional block to display conditional content
- if you are using classic views - you can use the [wpv-conditional] shortcode to display the conditional content.

Please check the following doc to get idea how you can use the conditional block:
=> https://toolset.com/course-lesson/using-toolset-conditional-block/

Please check the following doc to get idea how you can use the [wpv-conditional] shortcode:
=> https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/

In your case, if you are using block, you need to select the current user data and set your role and you can adjust the params for your link by adding the "Fields and Text" block within your conditional block.

Please let me know if you will require help to setup it.

#1745101

Minesh
Supporter

Languages: English (English )

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

Please check the following screenshot: hidden link

If you are adding "Conditional" block , then you should chose the option "Current user role" and set the static value option to compare and adjust your role value that you would like to compare. In the screenshot I'm comparing current user role with "author" role.

#1745193

My issue is resolved now. Thank's Minesh..:-)..