I am trying to show (or not show) fields on the form input based on age.
https://toolset.com/forums/topic/show-hide-custom-fields-for-users-based-on-age-calculated-from-date-field/
Here are the cred conditionals that are not working for me.Form filed is returning no field (whether I use "lt" or "gt". The logged in user is less than 18. The form field is not showing. I also have the conditional in the custom field conditional display since this needs to have the same conditional on output.
Conditional display: enlace oculto
Form:
[cred_show_group if="( $(usermeta='date-of-birth' output='raw' user_is_author='true') lt 'YEARS_FROM_NOW(-18)' )" mode="none"]
<div class="form-group">
<label>Parent or Legal Guardian Contact Info</label>
[cred_field field='parent-or-legal-guardian-contact-info' force_type='field' class='form-control' output='bootstrap']
</div>
[/cred_show_group]
Is this the correct syntax? Should I use something else?
Thanks much!
Here are the cred conditionals that are not working for me.Form filed is returning no field (whether I use "lt" or "gt". The logged in user is less than 18. The form field is not showing.
Hi, it depends on what you're trying to do here. In general, the cred_show_group syntax is used to show or hide one custom field based on the value of a second custom field that exists in the same Form. As changes are made in the second field, the conditional group is shown or hidden in response to those changes. This syntax should not be used to show or hide fields based on a saved value that is not represented by an input field in the current Form.
If you want to use a conditional based on a field that is not represented in the current Form, it's best to use conditional HTML instead of cred_show_group conditional groups.
So it looks like your conditional group is based on the value of a usermeta date field. If this post does not contain an input field for the date, you should not use cred_show_group. You should use the wpv-conditional syntax instead, as the value of DOB will not change during Form data entry.
This makes sense! Thanks! My issue is resolved now.