WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Contact Form 7 missing on_submit hook? (3 posts)

  1. zaus
    Member
    Posted 1 year ago #

    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 from additional_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?

    http://wordpress.org/extend/plugins/contact-form-7/

  2. nellone
    Member
    Posted 1 year ago #

    = 3.3 =
    * New: Introduce new additional setting on_submit. It works like on_sent_ok and has one-line JavaScript code, but on_submit code is fired regardless of whether or not the mail has been sent successfully.

  3. zaus
    Member
    Posted 1 year ago #

    nice, thanks for the update @nellone

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic