Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact form: add a redirect option #708

Closed
jeherve opened this issue Jun 13, 2014 · 11 comments · Fixed by #13745
Closed

Contact form: add a redirect option #708

jeherve opened this issue Jun 13, 2014 · 11 comments · Fixed by #13745
Assignees
Labels
[Feature] Contact Form [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Milestone

Comments

@jeherve
Copy link
Member

jeherve commented Jun 13, 2014

Jetpack’s contact form should need an option to redirect to a thank you page so that form conversions can be measured in popular analytics software like Google Analytics. Another option would be to fire a trackable event on the form submission so that an “event” is tracked in Google Analytics.

Here is a Jetpack add-on that adds such features:

Also suggested here:

@jeherve jeherve added this to the vFuture milestone Jun 13, 2014
@rase-
Copy link
Contributor

rase- commented Jun 13, 2014

👍 I like especially the idea of a trackable event. I would prefer to have an easily customizable success message over a redirect, though.

@kraftbj
Copy link
Contributor

kraftbj commented Jun 13, 2014

+1 Any improvement here would be great.

@richardmtl
Copy link
Contributor

I've seen at least one site that wasn't able to get 42u Booster working properly, so I also +1 this as a good feature to add.

@richardmtl
Copy link
Contributor

Another ticket where the 42U Booster didn't work properly, 1960571-t. A redirect option or the success message would be good to add.

@aheckler
Copy link
Member

Requested in 2063664-t.

@aheckler
Copy link
Member

Requested in 2176249-t.

@Christopher-Rose
Copy link

Any update on this?

A re-direct really ought to be a core function of any contact form and the 42U Jetpack Booster seems to be unmaintained as it is " Last Updated: 3 years ago Untested with your version of WordPress" My version being WP4.2.2

I hope this functionality can be expedited. Based upon the explanation in 42U, it doesn't seem very complex to implement: "To add a redirect to your Jetpack Contact Form, just add a text field named "redirect" to your form. It will be hidden on display.

From the HTML view, set the default value to the location where you would like the form to redirect after submission.

[contact-field label="redirect" type="text" default="/thanks/" /]

Note: you must replace the default each time after editing the form with the Jetpack WYSIWYG editor. The value is not saved by Jetpack.

Thanks

@kraftbj
Copy link
Contributor

kraftbj commented Jun 2, 2015

@Christopher-Rose - Updates will be posted here. There's a few folks who are planning on a larger review of the Contact Form, so not putting energy into enhancements deferring to the review.

@kraftbj
Copy link
Contributor

kraftbj commented Jun 17, 2015

This can be done programatically.

// Option 1: Redirect all forms to the same page.

add_filter('grunion_contact_form_redirect_url', 'jetpack_redirect_all_forms' );

function jetpack_redirect_all_forms(){
    return home_url( 'page_on_your_site' ); // e.g. 'thanks' for http://example.com/thanks. User wp_safe_redirect.
}

// Option 2: Selectively redirect forms to various pages.

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

function jetpack_redirect_some_forms( $redirect, $id ){ // $id represented the contact form's ID, found via the id attribute on the form.

    $redirects = array(
        '123' => home_url( 'page_on_your_site' ),
        '456' => home_url( 'another_page' ),
        '789' => home_url( 'page_on_your_site' ),
        );

    foreach ( $redirects as $origin => $destination ){
        if ( $id == $origin ) {
            return $destination;
        }
    }

    return $redirect; // None found, so do the default redirect.
}

@kraftbj kraftbj closed this as completed Jun 17, 2015
@TonyRidgway
Copy link

TonyRidgway commented Sep 25, 2016

Hand slap to the forehead moment when I saw how easy this was - Thank you kraftbj.

@jeherve jeherve modified the milestones: Not Currently Planned, 7.9 Oct 16, 2019
@jeherve jeherve assigned pento and unassigned georgestephanis Oct 16, 2019
@jeherve
Copy link
Member Author

jeherve commented Oct 16, 2019

This is being worked on in #13745

@jeherve jeherve reopened this Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Contact Form [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants