PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Redirect after failed form? Redirect to page w/ anchor?

  1. Hello fellow GravityFriends (hehe),

    Got a fairly straightforward question regarding a redirect to an anchored form when the submission was NOT successful. I have a form on a page that is at the bottom of the page that is linked to via an anchor...observe:

    http://www.cruinstitute.net/salon-services/

    The form is at the bottom at this link:

    http://www.cruinstitute.net/salon-services/#request-form

    The issue I am having is when someone does not fill in a missing field and needs to know that. Currently, I tried having the form redirect to the anchored URL, but once I hit submit, it just redirects to the page and drops the anchor. This is important because I want people to know their request was not sent and currently it just goes back to the page as if everything is all good.

    I suppose I could have it redirect to a page that says something to the effect of "This did not work" with a direct link to the form, but I don't want to do that extra work unless I know I have to.

    On that note, I was wondering if it could also redirect if the form does go through so they may see the confirmation, as well.

    Any help is appreciated! :)

    Posted 14 years ago on Wednesday September 8, 2010 | Permalink
  2. You can do this with a filter now.. this will enable a confirmation anchor for all forms.

    <?php add_filter("gform_confirmation_anchor", create_function("","return true;")); ?>

    or in this example, just for form id 5..

    <?php add_filter("gform_confirmation_anchor_5", create_function("","return true;")); ?>

    Posted 14 years ago on Thursday September 9, 2010 | Permalink
  3. Hmm...I think I know how to use this, but not entirely sure. I assume I load this into functions.php, but do I need to assign some extra custom values to it? Example, do I need load the URL or anchor into this filter? Such as:

    add_filter("gform_confirmation_anchor_5", create_function("#request-form","return true;"));

    I tried that but got (not so) unexpected errors. I loaded in the function as is to apply to all forms, but still no luck. When I submit the form without the required fields, it still does not 'jump' down to the form to let me know. :/

    Posted 14 years ago on Thursday September 9, 2010 | Permalink
  4. You shouldn't have to change or add anything, the anchor is added and named dynamically and the link is applied to the form action.

    added to functions.php file - screenshot

    and here's the markup that's added via the filter - screenshot

    Posted 14 years ago on Thursday September 9, 2010 | Permalink
  5. Doh! I didn't realize the anchor markup was being generated automatically, very nice. Thank you, Kevin, works great.

    Posted 14 years ago on Thursday September 9, 2010 | Permalink
  6. Good to hear. Thanks for the update.

    Posted 14 years ago on Thursday September 9, 2010 | Permalink
  7. hasanilx
    Member

    I added the function and can see the confirmation anchor in the source code, but on submit it scrolls up a little but user still can't see any errors without manually scrolling up.

    Please advise.

    http://www.tanicomanagement.com/contractors/contractor-sign-up-form/ (please pm for login as the site is not live) thx

    Posted 14 years ago on Friday October 8, 2010 | Permalink
  8. No PM here, you can send the login via our contact form if you'd like. Please reference this thread URL so we can refer back to it. Thanks.

    Posted 14 years ago on Saturday October 9, 2010 | Permalink
  9. hasanilx
    Member

    I sent login via contact no reply yet. Please let me know if I need to resend.

    Thx

    Posted 14 years ago on Monday October 11, 2010 | Permalink
  10. We are aware of the issue, have received your information and are looking into it. Keep in mind that this is Monday and your request was sent in over a weekend.

    Posted 14 years ago on Monday October 11, 2010 | Permalink
  11. hasanilx
    Member

    Got it. Note I put together another form using the default wp 3.0 theme and same issue. On submission does not scroll up to top despite having anchor.

    http://links.chazni.com/testform
    Thx

    Posted 14 years ago on Saturday October 16, 2010 | Permalink
  12. richardmtl
    Member

    I had a problem with this as well; it worked in FF and Chrome, but not IE.

    Posted 14 years ago on Thursday October 21, 2010 | Permalink
  13. Jeff
    Member

    Kevin, thanks for directing me here, but I have no idea what to do. I have read over and over, looked at the pictures, and not being a coder at all, I don't understand what I put where, exactly.

    In the professional theme I work with, I can have a custom.php file and custom.css file, for PHP and CSS that modifies the site without being concerned with updates.

    I am not usually this lost, however, I don't even know what question to ask, embarrassing.

    Jeff

    Posted 14 years ago on Monday November 1, 2010 | Permalink
  14. Jeff,

    You can open up your functions.php file inside your theme folder and add this to the end of it.

    <?php add_filter("gform_confirmation_anchor", create_function("","return true;")); ?>

    That should enable the anchor for all of your forms.

    You can add just this portion as long as it's in with other scripts and wrapped with the opening and closing php tags. ("<?php ?>")

    add_filter("gform_confirmation_anchor", create_function("","return true;"));

    Posted 14 years ago on Monday November 1, 2010 | Permalink
  15. Jeff
    Member

    Thanks Kevin, that was the paint by the numbers approach that worked for me. And the confirmation message displayed fine, in IE. If I see adverse results in other browsers, will post back.

    Jeff

    Posted 14 years ago on Monday November 1, 2010 | Permalink
  16. Glad that worked for you. Thanks for the update.

    Posted 14 years ago on Monday November 1, 2010 | Permalink
  17. Should this filter work for forms that are hard coded in the theme?
    I'm having the same issue with a form hard coded to the bottom of a template, adding the filter doesn't seem to produce the anchor - any help much appreciated!

    Thanks!

    Posted 13 years ago on Tuesday February 1, 2011 | Permalink
  18. When you say hardcoded do you mean that you are using the gravity_form() function to include the form? If so, it should still be working for you.

    Posted 13 years ago on Tuesday February 1, 2011 | Permalink
  19. Apologies, I have no idea what I did incorrectly earlier but I now have it working.
    Thanks!

    Posted 13 years ago on Wednesday February 2, 2011 | Permalink

This topic has been resolved and has been closed to new replies.