apply_filters ( 'grunion_contact_form_success_message', string $r_success_message )

Filter the message returned after a successful contact form submission.

Source file: modules/contact-form/grunion-contact-form.php

View in GitHub



(string) Success message.


Since: Jetpack 1.3.1

How to use this hook

See Using actions and filters to customize Jetpack.


You can use this filter to define your own message that will be displayed when folks submit a contact form on your site. In the example, below, we’ll use the filter to add one sentence before the existing success message.

 * Custom Feedback message past the submission.
 * @param string $r_success_message Success message.
function jetpackcom_custom_feedback_message( $r_success_message ) {
	return sprintf(
		'<div class="custom-feedback-feedback">%1$s</div>%2$s',
		esc_html__( 'Thanks for writing in. We will get back to you as soon as we can!', 'my-small-plugin' ),
add_filter( 'grunion_contact_form_success_message', 'jetpackcom_custom_feedback_message' );

Since this filter happens after a message has been saved on your site, you can also use it to delete form submissions from your database immediately after the message has been sent to you via email. Here is how you could go about it:

 * Delete the submitted entry once it's been used to send the mail and render the ok message.
 * @param string $r_success_message Confirmation after message was sent.
 * @return string Confirmation after message was sent.
function jetpackcom_delete_contact_form_submission( $r_success_message ) {
	if ( isset( $_GET['contact-form-sent'] ) && ctype_digit( $_GET['contact-form-sent'] ) && 'feedback' === get_post_type( $_GET['contact-form-sent'] ) ) {
		wp_delete_post( intval( $_GET['contact-form-sent'] ), true );
	return $r_success_message;
add_filter( 'grunion_contact_form_success_message', 'jetpackcom_delete_contact_form_submission' );

Have a note to contribute?