- This topic has 1 reply, 2 voices, and was last updated 9 months, 2 weeks ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › Conditional Validation for Form Builder
Hello Support Team,
I am using the Simple Membership plugin with the Form Builder addon.
I need to set up conditional validation for one of my custom fields (Teen Email – field name/ID: swpm-30).
Specifically:
If the URL contains a parameter teen_email, then this field should not be required (validation skipped).
If the URL does not contain teen_email, then the field should remain required.
I have tried the following code (based on the swpm_fb_front_end_registration_form_submitted hook), but it did not work:
add_action('swpm_fb_front_end_registration_form_submitted', function(&$sanitized) {
// If teen_email is present in the URL
if (isset($_GET['teen_email']) && !empty($_GET['teen_email'])) {
if (isset($sanitized['swpm-30'])) {
$sanitized['swpm-30'] = '';
}
}
}, 10, 1);
it does not actually bypass the required validation.
Can you please confirm:
1) Which is the correct action/filter hook to use for custom conditional validation in the Form Builder?
2) How can I override the “required” validation for this field only when teen_email exists in the URL?
This is an important requirement for our workflow, and any code snippet or guidance would be very helpful.
Thank you,
Dhruv
For support with Premium Addons, please complete a Premium Addon Support ticket.
https://simple-membership-plugin.com/premium-addon-support/