Reply To: Verify Submitter’s Email Address

Home Forums Quform WordPress Verify Submitter’s Email Address Reply To: Verify Submitter’s Email Address

#31850
MediaServices
Participant

Thank you. I cannot get this code to work.

UPDATED BELOW TO REFLECT functions.php correction. Last year’s minimum vote counting was not working and I got that fixed by going back to an earlier version of my functions.php and re-entering the code. I still cannot get the code above to work fully. Details below.

  • We are running Quform 2.0 for WordPress on this form.
  • Our form is #15. [quform id="15" name="description goes here"]
  • In the first line of your code, I’ve left ‘quform_post_validate_1 unchanged’
  • In the second line of code after setValue I’ve changed ‘quform_1_729’ to ‘quform_1_340’, and ‘quform_15_340’.
  • Our hidden field’s unique ID as seen here https://support.themecatcher.net/quform-wordpress-v2/guides/basic/finding-the-element-unique-id is 15_340. All occurrences of 729 have been changed to 340
  • Our checkbox field’s unique ID as seen here https://support.themecatcher.net/quform-wordpress-v2/guides/basic/finding-the-element-unique-id is 15_341. 729 has been changed to 341
  • For the autoreply email I’ve edited the link from <a href="https://www.example.com/confirm-vote?key={element|id:729|Hidden}">CLICK HERE TO CONFIRM YOUR VOTE</a> to match our form <a href="http://www.myexamplesite.com/my-confirm-form/?key={element|id:729|Hidden}">CLICK HERE TO CONFIRM YOUR VOTE</a>
    </il>

    UIPDATED
    I will list my code below, but first here’s what happens. I fill out the form and click the SEND button and get my Confirmation message that voting has been successful, please check our email. I receive an email with the link, but the ?key= is always blank, so the URL to click is http://www.myexamplesite.com/my-confirm-form/?key= and when I click it and land on my confirmation I am now getting the error message ‘Vote failed, key not found.’.

    Of course no validation checkbox fields have Yes as their value, all of them are empty even after I click on the link sent by email.

    SAMPLE 1: quform_1_340 for setValue

    
    add_filter('quform_post_validate_1', function (array $result, Quform_Form $form) {
        $form->setValue('quform_1_340', sha1(uniqid()));	
    
        return $result;
    }, 10, 2);
    
    add_shortcode('confirm_vote', function () {
        if (!isset($_GET['key']) || !is_string($_GET['key'])) {
            return 'Vote failed, key missing.';
        }
    
        global $wpdb;
        $repository = quform('repository');
        $query = "SELECT entry_id FROM " . $repository->getEntryDataTableName() . " WHERE element_id = 340 AND value = %s";
        $result = $wpdb->get_var($wpdb->prepare($query, $_GET['key']));
    
        if ($result == null) {
            return 'Vote failed, key not found.';
        }
    
        $repository->saveEntryData($result, array(340 => '', 341 => serialize(array('Yes'))));
    
        return 'Thank you, your vote has been confirmed.';
    });
    

    SAMPLE 2: quform_15_340 for setValue

    
    add_filter('quform_post_validate_1', function (array $result, Quform_Form $form) {
        $form->setValue('quform_15_340', sha1(uniqid()));	
    
        return $result;
    }, 10, 2);
    
    add_shortcode('confirm_vote', function () {
        if (!isset($_GET['key']) || !is_string($_GET['key'])) {
            return 'Vote failed, key missing.';
        }
    
        global $wpdb;
        $repository = quform('repository');
        $query = "SELECT entry_id FROM " . $repository->getEntryDataTableName() . " WHERE element_id = 340 AND value = %s";
        $result = $wpdb->get_var($wpdb->prepare($query, $_GET['key']));
    
        if ($result == null) {
            return 'Vote failed, key not found.';
        }
    
        $repository->saveEntryData($result, array(340 => '', 341 => serialize(array('Yes'))));
    
        return 'Thank you, your vote has been confirmed.';
    });
    

    I have also tried changing line 1 ‘quform_post_validate_1’ to ‘quform_post_validate_15’.

    I look forward to your reply.

  • This reply was modified 3 years, 7 months ago by MediaServices. Reason: Added another detail
  • This reply was modified 3 years, 7 months ago by MediaServices. Reason: Added CODE tags around link code
  • This reply was modified 3 years, 7 months ago by MediaServices. Reason: Fixed typo
  • This reply was modified 3 years, 7 months ago by MediaServices. Reason: UPDATE functions.php Correction
  • This reply was modified 3 years, 7 months ago by MediaServices.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy