• Resolved kaseynova

    (@kaseynova)


    I want to direct my visitor to a page where they can download a free ebook once they hit the submit button. Any help is appreciated!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The 1.1.1 release actually ended up adding a filter to help with this exact thing: https://plugins.trac.www.ads-software.com/browser/constant-contact-forms/trunk/includes/class-display.php#L144

    Admittedly there’s no UI for setting this, so it’ll have to be all code-based, but it should work.

    Thread Starter kaseynova

    (@kaseynova)

    I’m not sure what I’m supposed to do with this?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Like I said in my first reply, it’s definitely a code-based tweak to handle at the moment, so if you have someone else available, who is more of a coder, to help with the site, they should be able to help.

    You’ll need to do something like this from your theme’s functions.php file, since we don’t have any UI for setting this.

    function my_custom_redirect_url( $original_destination ) {
        return 'https://www.mydomain.com/ebook';
    }
    add_filter( 'constant_contact_front_form_action', 'my_custom_redirect_url' );
    

    This way, you can provide your own url for the form to send the user to after submission.

    This filter seems to simply redirect on submit and not actually process the form. At least, the contacts that I submit do not end up in my contacts list, but when I don’t use this filter and process the form normally they do. Not sure if Im missing something simple, but any help would be appreciated. Thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @willgorham appears that the processing of the form was more reliant on the presence of the shortcode/form than I realized. I’m tracing my way through, and the methods that do the processing are tied to the shortcode code that does the display.

    Looks like we’ll need to work out how to process the form regardless of where the user is directed to, and keep the posted data in account.

    Filing a bug now.

    @tw2113 Thanks for the quick response.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    This at least sort of works, for an interim solution:

    function wpforums_custom_process_ctct_form() {
    	if ( empty( $_POST ) ) {
    		return;
    	}
    
    	// Fill in the ID of the form you're processing for, in place of the '4'
    	if ( ! isset( $_POST['ctct-id'] ) && ( '4' != $_POST['ctct-id'] ) ) {
    		return;
    	}
    
    	return constant_contact()->process_form->process_form();
    }
    add_action( 'wp_head', 'wpforums_custom_process_ctct_form' );
    

    Basically we check for some specific values, plus check to see if we’re dealing with the correct form intended, and if so, process the form itself. The user ends up on the filtered action parameter url, but the success messages aren’t handled in this. Not a 100% solution, but would work to certain degrees.

    please help me understand how I would create multiple different forms, and send each one of them to a different landing page. It’s very common for a signup form to have a free PDF on the backside.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    hi @rockyjones2112

    Right now, the best option we have for this is going to be the following filter:

    /**
     * Filters the action value to use for the contact form.
     *
     * @since 1.1.1
     *
     * @param string $value   Value to put in the form action attribute. Default empty string.
     * @param int    $form_id ID of the Constant Contact form being rendered.
     */
    $form_action = apply_filters( 'constant_contact_front_form_action', '', $form_id );
    

    It is most definitely a code solution, but it would technically work for the moment. You’d want to use the form ID value passed in to conditionally set where to redirect the user after they hit submit.

    If you are on version 1.2.3 or 1.2.4, ignore this paragraph. If you are not on version 1.2.3 or higher, you will also need to utilize the code found in my reply here so that the form is actually processed and submitted. Though I believe you could probably remove the ctct_id value checking. Just make sure it’s set https://www.ads-software.com/support/topic/redirect-form-after-submit-2/#post-8745634

    That said, we are looking to get a UI field in the form editor area to set these, per-form, but that’s not out the door yet.

    I guess I’m openly wondering why I wouldn’t just use the Mail Munch plugin instead.

    https://www.ads-software.com/plugins/constant-contact-forms-by-mailmunch/

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I guess it comes down to which has the features you immediately need.

    “Constant Contact Forms” plugin is still a rather young plugin, and we are always taking user feedback and iterating when and where possible to help meet their needs as best we can.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Redirect form after submit’ is closed to new replies.