Quform V2: Minimum Number of Responses?

Home Forums Quform WordPress Quform V2: Minimum Number of Responses?

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27880
    MediaServices
    Participant

    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, 4 months ago by MediaServices. Reason: Improve CODE block by removing spaces
    #27903
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy