WordPress: Is Contact Form 7 missing on_submit callback?

Original question: http://wordpress.org/support/topic/contact-form-7-missing-on_submit-hook

Is it just me, or is the on_submit javascript callback missing from Contact Form 7’s “Additional settings”?

In the additional_settings section of each form, you can use on_sent_ok, but is there a similar on_failure, or even just an after_submission?

I’ve looked through the code, and in the scripts.js file there’s a section for “callbacks” using the onSentOk aspect of the response (refers to on_sent_okay fromadditional_settings, and another identical section for processing onSubmit (which was reported in v2.0.6 changelog). However, I can’t find any mention of onSubmit or on_submit in the rest of the code, and adding something like on_submit: alert('testing here'); does nothing.

Once I “manually” attach the setting to the ajax response with the following, it works.

Pastebin: http://wordpress.pastebin.ca/2158913

add_filter( 'wpcf7_ajax_json_echo', array(&$this, 'ajax_results_append') );
public function ajax_results_append($items, $results){
	global $wpcf7_contact_form;

	$items['onSubmit'] =     $wpcf7_contact_form->additional_setting( 'on_submit', false );

	// send it back because it's a filter
	return $items;
}

Is this a bug, or am I missing something?

2 thoughts on “WordPress: Is Contact Form 7 missing on_submit callback?

  1. Hi,

    We have requirement where in we have two radio buttons in a form “PayPal” or “Direct debit”. When selected either of them it should redirect to respective accounts payment page. For redirection we had used the piece of code in additional settings as mentioned in this link https://wordpress.org/support/topic/wordpress-contact-form-7-radio-button-conditional-redirect/. But it does not seem to redirect to first condition instead it redirects to else condition irrespective of options chosen. Could you please suggest some solution for this one?

    Also how can we pass in the text field value to PayPal amount section in PayPal billing page?

    We would be glad if you could help us out with a solution for the above at the earliest.

    Thanks much in advance. Hoping to hear from you soon.

Leave a Reply

Your email address will not be published. Required fields are marked *