Home › Forums › Quform WordPress › Minimum Number of Responses – Multiple Forms
- This topic has 3 replies, 2 voices, and was last updated 5 years, 6 months ago by
MediaServices.
- AuthorPosts
- September 3, 2019 at 10:37 pm #29889
MediaServices
ParticipantSince v1 we’ve used Quform for online voting (among other things) and last year I posted https://support.themecatcher.net/forums/topic/quform-v2-minimum-number-of-responses and got code for v2. We’ve taken our main voting form and this year we’ve also done separate smaller forms for Social Media-driven votes. I want to be able to tell people when they have not entered enough votes and I’ve tried eediting the code you sent me from last year and cannot get it working. These are the pages where we have the form and we want to make sure a certain number of votes are entered.
http://mountpleasantmagazine.com/bestofballot/ (15+ votes)
http://mountpleasantmagazine.com/bomp-pets/ (3+ votes)
http://mountpleasantmagazine.com/bomp-entertainment/ (5+ votes)
http://mountpleasantmagazine.com/bomp-personalities/ (5+ votes)
http://mountpleasantmagazine.com/bomp-shopping/ (5+ votes)
http://mountpleasantmagazine.com/bomp-food/ (5+ votes)
http://mountpleasantmagazine.com/bomp-health/ (5+ votes)I tried doing the code for the first one and here’s what I got, and it didn’t work. I also suspect I may run into problems with the code as-is because there are now multiple forms being checked.
add_filter('quform_element_valid_4_6', function ($valid, $value, $el) { $votes = 0; $ignoreElements = array( 'quform_3_1', // first name 'quform_3_8', // email 'quform_3_7', // zip /* 'quform_4_10' // recaptcha --NO RECAPCHA ELEMENT NAME?? */ ); foreach ($el->getForm()->getRecursiveIterator() as $element) { if (!$element instanceof Quform_Element_Text) { continue; } if (in_array($element->getName(), $ignoreElements)) { continue; // Ignore non-vote fields } if (!$element->isEmpty()) { $votes++; } } if ($votes < 15) { $el->addError('At least 15 votes are required'); $valid = false; } return $valid; }, 10, 3);
Can you please assist?
September 3, 2019 at 10:54 pm #29890MediaServices
ParticipantWe also have some other forms that we want to do this with, and hopefully I can just edit your code for those.
September 12, 2019 at 11:29 am #29927Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 18, 2019 at 8:04 pm #29960MediaServices
ParticipantThanks, that worked perfectly.
- AuthorPosts
- You must be logged in to reply to this topic.