Support Home > Utilities > Advanced Contact Form Customization

Advanced Contact Form Customization

We’ve made a few “filters” available for use with the Jetpack Contact Form. You can use these to achieve the following tasks:

  1. Change the success message after a form is submitted.
  2. Redirect your readers to a specific page on your site after a form is submitted.
  3. Customizing the email headers submitted with the form.

Code should be added to your WordPress theme’s functions.php file. An easy and safe way to do this is by using the Code Snippets plugin.

Change the success message

The following example shows how to use the grunion_contact_form_success_message filter to specify a custom success message for page ID 10 while setting a generic message for the rest of the forms on your site:

function jetpackcom_contact_confirmation() {
    if ( is_page( '10' ) ) {
        $conf = __( 'A special confirmation message for the form you added to page 10', 'plugin-textdomain' );
    } else {
        $conf = __( 'A generic confirmation message to display for all the other forms', 'plugin-textdomain' );
    return $conf;

add_filter( 'grunion_contact_form_success_message', 'jetpackcom_contact_confirmation' );

Note: If you are using the Block Editor, you can set this directly in the block settings. The filter is useful for sites using the Classic editor.

See the developer documentation for more.

Redirect after form submission

The following example shows how to use the grunion_contact_form_redirect_url filter to handle a redirect upon form submission:

 * Jetpack Contact Form Custom Redirections.
 * @param string $redirect Post submission URL.
 * @param int $id Contact Form ID.
 * @param int $post_id Post ID.
 * @return string $redirect Custom Post submission URL.
function jetpackcom_custom_form_redirect( $redirect, $id, $post_id ) {
     * Create a list of pages where you've inserted forms.
     * For each contact Form ID (found via the id attribute on the form),
     * set up a custom URL where the user will be redirected.
    $redirects = array(
        '1370' => home_url( 'page_on_your_site' ),
        '2239' => home_url( 'another_page' ),
        '1370' => home_url( 'page_on_your_site' ),
    // Let's loop though each custom redirect.
    foreach ( $redirects as $origin => $destination ) {
        if ( $id == $origin ) {
            return $destination;
    // Default Redirect for all the other forms.
    return $redirect;

add_filter( 'grunion_contact_form_redirect_url', 'jetpackcom_custom_form_redirect', 10, 3 );

See the developer documentation for more info.

Customize email headers

The following example shows how to use the jetpack_contact_form_email_headers filter to add a BCC header when the form is submitted:

	function ( $headers, $comment_author, $reply_to_addr, $to ) {
		$headers .= 'Bcc: ' . $reply_to_addr . "\r\n";
		return $headers;

Warning: This filter is an advanced feature and can open your site up to abuse if used incorrectly. Do not add headers or header data from the form submission without proper escaping and validation. Especially do not take email addresses from the form data to add as CC or BCC headers without strictly validating each address against a list of allowed addresses first.

See the developer documentation for more info.

  • Categories

  • Contact Us

    Need more help? Feel free to contact us.