• Resolved jberg1

    (@jberg1)


    Is there anyway I can get the user back to the form location after submission to see the Thank You message? Everything works fine, it is just that I have my form in the footer so after submission it just reloads the page. It would be nice if jumped to a anchor tag/id to the form location.

    For example giving the .ctct-form-wrapper a general ID that could be used in the form action. #ctct-form or something.

    Or possibly setting a redirection URL in the form creation area to set up a static thank you page.

    Thanks for any help.

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

    (@tw2113)

    The BenchPresser

    Good day @jberg1

    Will take down your suggestion regarding the anchor for possible usage on the <form> tag.

    Regarding the other parts of your response, there is already a filter for the form action:

    /**
      * 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 );
    
    // Build out our form.
    $return .= '<form class="ctct-form" id=' . $rf_id . ' action="' . esc_attr( $form_action ) . '" method="post">';
    

    It defaults to an empty string, which will have the form submit to the URL the user is already on. You can pass it your own value. Also, in 1.3.0, we’re planning to include a field for this in the UI when creating or editing the form, leaving less need for coding on our user’s part. It’s something for the moment.

    Thread Starter jberg1

    (@jberg1)

    Ah ha! Exactly what I was looking for, thanks.

    //Form Action for Constant Contact Forms
    function replace_form_action() {
    	$value = '#footer';
    	return $value;
    }
    add_filter( 'constant_contact_front_form_action', 'replace_form_action' );

    How would I go about only adding this to a specific form ID? Or is there a better way to write my code above? I see the filter is using $form_id, just not sure how to pass that in my function.

    Thanks again.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Try this out:

    function replace_form_action( $action, $form_id ) {
    	if ( 142 == $form_id ) {
    		return '#footer';
    	}
    	return $action;
    }
    add_filter( 'constant_contact_front_form_action', 'replace_form_action', 10, 2 );
    
    Thread Starter jberg1

    (@jberg1)

    Perfect! Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Come back to thank you message.’ is closed to new replies.