Home › Forums › Quform WordPress › Quform V2: Minimum Number of Responses?
This topic is: not resolved
- This topic has 1 reply, 2 voices, and was last updated 5 years, 12 months ago by Ally.
Viewing 2 posts - 1 through 2 (of 2 total)
- AuthorPosts
- November 28, 2018 at 8:24 pm #27880MediaServicesParticipant
I posted https://support.themecatcher.net/forums/topic/minimum-number-of-responses which used Quform V1 and we needed to insure at least 15 responses were made in the voting portion of the form and your solution worked perfectly. We now have a form at http://isleofpalmsmagazine.com/best-of-the-islands/ that uses Quform V2 and I wanted to make sure the following code would work in the functions.php file to make sure we have at least 10 votes on this form….
add_filter('quform_element_valid_iphorm_4_6', function ($valid, $value, $el) { $votes = 0; $ignoreElements = array( 'quform_4_3', // first name 'quform_4_4', // email 'quform_4_5', // city 'quform_4_6', // zip 'quform_4_10' // recaptcha ); foreach ($el->getForm()->getElements() as $element) { if (in_array($element->getName(), $ignoreElements)) { continue; // Ignore non-vote fields } if (!$element->isEmpty()) { $votes++; } } if ($votes < 10) { $el->addError('At least 10 votes are required'); $valid = false; } return $valid; }, 10, 3);
- This topic was modified 5 years, 12 months ago by MediaServices. Reason: Improve CODE block by removing spaces
November 30, 2018 at 6:15 pm #27903AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.