Title: Hooking Form Submit
Last modified: March 30, 2017

---

# Hooking Form Submit

 *  [bitscraper](https://wordpress.org/support/users/bitscraper/)
 * (@bitscraper)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/hooking-form-submit/)
 * What’s the best way to hook the form submit and access the data that was submitted?
 * I’ve tried hooking using add_action-
 * wpcf7_submit
    wpcf7_before_send_mail wpcf7_form_response_output
 * and I can get the form itself when it was submitted, but not the data that the
   user inputted into the form.
 * Thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [tmargot](https://wordpress.org/support/users/tmargot/)
 * (@tmargot)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/hooking-form-submit/#post-9045188)
 * Hi,
 * Did you find an answer to this as I require the same info?
 * Cheers,
    Tristan
 *  [tmargot](https://wordpress.org/support/users/tmargot/)
 * (@tmargot)
 * [9 years ago](https://wordpress.org/support/topic/hooking-form-submit/#post-9120703)
 * Hoping this will help someone trying to learn everything at once, the following
   worked out for me. As a start use the following in your functions.php…
 *     ```
       add_action( 'wpcf7_mail_sent', 'do_my_work' ); //access after send
   
       if( ! function_exists( 'do_my_work' ) ) {
       	function do_my_work($cf7){ //contact form object passed in
   
       		/* Use WPCF7_Submission object's get_posted_data() method to get it. */
       		$submission = WPCF7_Submission::get_instance();
       		$posted_data = $submission ? $submission->get_posted_data() : null; //get form data
       		if($posted_data){ 
       			$formName = $posted_data['your-name']; //get form field value
   
       			// do something more
   
       		}	
       	}
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hooking Form Submit’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [tmargot](https://wordpress.org/support/users/tmargot/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/hooking-form-submit/#post-9120703)
 * Status: not resolved