Skip Navigation

[Resolved] How to conditionally display a form depending on a User Custom Field value

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

Problem:
How to conditionally display a form depending on a User Custom Field value

Solution:
You should try to use the [wpv-conditional] shrotcode in order to display the form conditionally based on custom user field value.

For example:

[wpv-conditional if="(  '[types usermeta="orc-credits" user_current="true" output="raw"][/types]' gt 0 )"]
  
Your form goes here
  
[/wpv-conditional]

Relevant Documentation:
=> https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created 3 years, 9 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 4 replies, has 2 voices.

Last updated by KeithM7209 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2010673

Tell us what you are trying to do?
I have a Custom Field for Users (called 'ORC Credits'), what I want to do is to conditionally display a Toolset Post Form (Called 'Reference Input for this example), depending on the value of the logged in Users 'ORC Credits' field.
Basically, if they do not have any ORC Credits, then I don't want them to be able to see the form or input into it, so if they have '0' ORC Credits, then I want them to see a message instead which says 'You do not have any credits, you must purchase new credits before you can input a new Reference'.

Is there any documentation that you are following?
I tried wrapping my code (in Expert Mode in the Form Builder) using code from this article = https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/ and also using the example I was very kindly supplied with in a separate ticket from a few months ago (https://toolset.com/forums/topic/allow-users-to-input-a-set-number-of-posts-via-user-form/), so I tried this:

[cred_show_group if="( ( '[types usermeta="orc-credits" output="raw" current_user="true"][/types]' gte '1' ) ) "]
[/cred_show_group]
However, this does not work, all that happens is, I see that exact code appear as text in my page on the front end.

Is there a similar example that we can see?
No

What is the link to your site?
hidden link (Can I hide this link please?)
Thats the link to the page, but you won't be able to see it as it is only visible to a specific User Role (which requires authentication of course).

Thank you very much for your help,

Keith

#2010689

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please try to use the [wpv-conditional] shrotcode in order to display the form conditionally.

[wpv-conditional if="(  '[types usermeta="orc-credits" user_current="true" output="raw"][/types]' gt 0 )"]
 
Your form goes here
 
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

#2010779

Minesh - thank you SO MUCH !!! 🙂

I can confirm this works - I could kiss you haha

#2010783

Minesh
Supporter

Languages: English (English )

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

Glad to know that solution I shared help you to resolve your issue. You are welcome to mark resolve this ticket.

#2010809

My issue is resolved now. Thank you!