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.

Detect if submitted form is valid

  1. borsattoc
    Member

    Hello,

    I have a question regarding form submission. I'd like to hide a message on my page only when users submit my form.

    How can I detect if submitted form is valid?

    I'm trying to do something like this in my template page:

    <h1 <?php post_class(); ?>><?php the_title(); ?></h1>
    				<?php if(empty($_POST) /* || $_POST && invalid data supplied */ ): ?>
    					<?php the_content(); ?>
    				<?php else: ?>
    					<?php _e("Thank you for contacting us. We have received your message and will do our best to reply within one working day.","gravity_form") ?>
    				<?php endif; ?>

    Thank you for your support

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  2. David Peralty

    We have confirmations built into Gravity Forms to display messages relating to successful form submissions. Would they not be what you need?

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  3. borsattoc
    Member

    Unfortunately they do not fit my needs.
    What I have to do is to show a message like "For information bla bla fill the form below".

    Then, after submission, it shows a message like:
    "For information bla bla fill the form below. Thank you for contacting us".

    What I need is to hide "For information bla bla fill the form below" after the form has been successfully submitted.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  4. Richard Vav
    Administrator

    Could you place the "For information bla bla fill the form below" message in the form description on the form settings page because that would be replaced by the confirmation message on successful submission.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  5. borsattoc
    Member

    I must use page content because the website is running in 5 different languages and every page translation has different shortcodes. I cannot use a single text for description unless I create a different form for each language (which is not a good solution since we are using wpml to translate strings).

    So here we come back to the original question. Is there a method to detect if submitted form is valid?

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  6. David Peralty

    No, there is no way using PHP to grab if a form has been successfully submitted, unless you redirect to the page using URL redirect and include a query string. Then you could have your url include:

    ?frmsuccess=1

    And then test against that using PHP to hide your message.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  7. borsattoc
    Member

    I cannot use a single URL becase every contact page has a different URL containing lang info (eg. /de/contact, es/contacto it/,contatti etc). I tried using a relative URL such as ?sent=true but you use parse_url inside handle_confirmation() and it fails redirecting me to the homepage.

    I'll try to figure out a different approach.
    Thank you for your time.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  8. David Peralty

    Sorry I couldn't be of more help, but your unique circumstances limit what can be done. All my best.

    Posted 10 years ago on Monday July 8, 2013 | Permalink

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