• We have set up an automatic autoresponder based on a field input by adding an additional function. However, now it sends directly. What we would like is to send only that autoresponder after a delay, so the form itself may be send immediately.

    I tried doing that by adding sleep() into the function, but then the person filling the form will also see the loading animation till that time is collapsed.

    Current code:

    //Autoresponder CF7
    add_action( 'wpcf7_mail_sent', 'contact_form_autoresponders' );
    
    function contact_form_autoresponders( $contact_form ) {
        // The contact form ID.
        if ( 47507 === $contact_form->id ) {
            $submission  = WPCF7_Submission::get_instance();
            $posted_data = $submission->get_posted_data();
            // Dropdowns are stored as arrays.
            if ( isset( $posted_data['location'] ) ) {
                switch ( $posted_data['location'][0] ) {
                    case 'California':
                        $msg = 'California email body goes here';
                        break;
                    case 'Texas':
                        $msg = 'Texas email body goes here';
                        break;
                    default:
                        $msg = 'Unfortunately, that location is not available';
                }
                // mail it to them using wp_mail.
                wp_mail( $posted_data['your-email'], 'Thanks for your enquiry', $msg );
            }
        }
    }

    How can I add a delay to the autoresponder and still have the confirmation of the filled in form show immediately for the person that fills it in.

    The page I need help with: [log in to see the link]

The topic ‘Delay Autoresponder CF7’ is closed to new replies.