Skip Navigation

[Resolved] Conditional text message on select field

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#558254

Hi, I was wondering if you could help, or point me in the right direction. I can't seem to find the support documentation that would help me with this problem.

I have a CRED user registration form. When a new user registers, they can choose to be either a Business or a Personal use customer from a select field. I have done that using a generic field in my CRED form.

[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
[/cred_generic_field]

I want to display a conditional message if a user selects Personal use. So...

IF the user picks Business from the drop down the registration form functions as normal BUT
IF the user picks Personal from the drop down a message is displayed something like "Personal customers can only purchase products in the Personal Category" They don't need to check anything, just see the message.

Thanks!

#558298

Hi, CRED conditional display is described in this document:
https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/

The general idea is that you add the message into your CRED form editor and style it how you want it to appear for Personal users, then apply a conditional statement around the message using a CRED Conditional Group. That conditional is based on the value selected in your generic field. There's a wizard-style interface that you can use to build the conditional statements, so you shouldn't need to copy + paste any code.

Example:

[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
[/cred_generic_field]


[cred_show_group if="($(cred-conditional-select) eq  'personal' )"  mode='fade-slide']
 Personal message here!
[/cred_show_group]
#558529

Hi really sorry i tried this using the conditional wizard and it made the whole select vanish. Here is what I tried.

[cred_show_group if="($(user_select_role) eq 'personal' )" mode='fade-slide']
[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
message here
[/cred_generic_field]
[/cred_show_group]

#558652

Take a closer look at the example I showed, and you will see that the cred_show_group element does not wrap around the select field. It is a separate element. As you have it set up now, the conditional wraps around the element that sets the value the conditional tests - not really useful.

Move the "message" outside of the generic select field and into the cred_show_group element. Then close the cred_show_group element before opening the generic field element. Like this:

[cred_show_group if="($(user_select_role) eq 'personal' )" mode='fade-slide']
message here
[/cred_show_group]

[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
[/cred_generic_field]
#558904

Thank you that worked perfectly!

I now need to show a different message if the user selects Business Account. So I did this... But that made the select vanish again

<label class="cred-label">
<h3>Help us to streamline your shopping process by picking your account type</h3>
</label>
[cred_show_group if="($(user_select_role) eq 'personal' )" mode='fade-slide']
[vc_message]Personal Accounts will only be able to purchase A[/vc_message]
[/cred_show_group]
[cred_show_group if="($(user_select_role) eq 'business' )" mode='fade-slide']
[vc_message]Personal Accounts will only be able to purchase B[/vc_message]
[/cred_show_group]

[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
[/cred_generic_field]

#559329

That's strange, I don't see anything obviously wrong. Please try to remove the vc_message shortcodes first to eliminate those as a potential problem. If that does not resolve the issue, I'll probably need access to your admin area to investigate further. If that's okay with you, please provide login credentials in the private reply fields here. Let me know where I can find the CRED form on your site, and I will take a look.