• Hi, i want to retrieve all the fields filled by customers in the last step before sending the email or even super better on the thank you page.

    Can you suggest me something?
    I will dig deeper on my own

    • This topic was modified 3 years, 5 months ago by appraily.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author webheadcoder

    (@webheadllc)

    Hi,

    You would need to hook into the wpcf7_mail_sent hook and call the WPCF7_Submission::get_instance()->get_posted_data() function.

    Hello,

    I was wondering if you could send a sample code, because I am having problems making WPCF7_Submission::get_instance()->get_posted_data() run.
    Also does the code need to be added in the functions.php file? Or is it somewhere else.

    function action_wpcf7_mail_sent( $contact_form ) { 
    	//if (!isset($cfdata->posted_data) && class_exists('WPCF7_Submission')) {
    		$submission = WPCF7_Submission::get_instance();
    		echo "attempting";
    		if ( $submission ) {
    			$form_data = $submission->get_posted_data();
    			echo $form_data["your-name"];
    			// now $form_data contains the form values,
    			// so you can do, for example $form_data['email'], instead of $_POST['email']
    
    		}else{
    			echo "fail";
    			// we got nothing; something went wrong
    		}
    	//}
    	return $contact_form;
    }; 
             
    // add the action 
    add_action( 'wpcf7_mail_sent', 'action_wpcf7_mail_sent' ); 

    this is my code so far.

    function action_wpcf7_mail_sent( $contact_form ) { 
    	$submission = WPCF7_Submission::get_instance();
    }; 
    add_action( 'wpcf7_mail_sent', 'action_wpcf7_mail_sent' ); 

    the code stops here already. I did not make the forms, but as far as i know, there are 2 forms: one to input all the data and another to check the data and confirming if it’s correct.
    when i put this piece of code in functions.php the website stops at the loading between the submission form and the confirmation form.

    It could also be that the problem is unrelated tot his plugin, if so please let me know.
    Thanks in advance

    It…looks like it started working.
    Not sure why, I will update as soon as I understand.
    I still have little experience with wordpress so it is still confusing.

    Thread Starter appraily

    (@appraily)

    Hi guys,
    if anyone interested i found a code free solution that is working smooth and nicely:

    Redirection for Contact Form 7 – Plugin

    Works as charm.
    Regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Retrieve Fields on Thank you pages or last step’ is closed to new replies.