Skip to content

Instantly share code, notes, and snippets.

@freshdevelop
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save freshdevelop/9228001 to your computer and use it in GitHub Desktop.

Select an option

Save freshdevelop/9228001 to your computer and use it in GitHub Desktop.
[WP CF7] - Additional Setting "on_mail_failed"
File path: contact-form-7/includes/classes.php
} else {
$result['status'] = 'mail_failed';
$result['message'] = $this->message( 'mail_sent_ng' );
// Edit start ---------------
$on_sent_failed = $this->additional_setting( 'on_sent_failed', false );
if ( ! empty( $on_sent_failed ) )
$result['scripts_on_sent_failed'] = array_map( 'wpcf7_strip_quote', $on_sent_failed );
// Edit end -----------------
do_action_ref_array( 'wpcf7_mail_failed', array( &$this ) );
}
File path: contact-form-7/includes/controller.php
if ( ! empty( $result['scripts_on_sent_ok'] ) )
$items['onSentOk'] = $result['scripts_on_sent_ok'];
// Edit start ---------------
if ( ! empty( $result['scripts_on_sent_failed'] ) )
$items['onSentFailed'] = $result['scripts_on_sent_failed'];
// Edit end -----------------
if ( ! empty( $result['scripts_on_submit'] ) )
$items['onSubmit'] = $result['scripts_on_submit'];
File path: contact-form-7/includes/js/scripts.js
} else {
$responseOutput.addClass('wpcf7-mail-sent-ng');
$form.addClass('failed');
// Edit start ---------------
if (data.onSentFailed)
$.each(data.onSentFailed, function(i, n) { eval(n) });
// Edit end -----------------
$(data.into).trigger('mailfailed.wpcf7');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment