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.

Custom field validation and user registration

  1. I have custom validation on a form that checks a "registration code" field against a database to see if that code has been used yet, and if not it will set that code to "used". This form also registers users via the user registration add-on.

    I'm having a problem where if the user registration fails because the username has already been taken, the form does not submit but the registration code gets set to "used" in the database. My guess is that since the user registration is an add-on, all the normal validation checks get verified first and then the user stuff checks run separately. I could very well be wrong though :)

    Do you know of a way I can make this right so that my gform_field_validation does not update my database values until after the form is fully validated?

    *edit*
    I think it must be happening on more than just "user name already registered". The site is live and people are trying to register and having problems, I can't imagine all of the problems were linked to duplicate user names.

    Thanks!

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  2. Hi JnJ,

    The code that validates the custom registration code should not set the registration code to used. It should only validate whether or not it is used. You'd want to hook a separate function to the gform_post_submission function that would mark the registration code as used. This way the code is only marked as used upon a successfully submission.

    Posted 13 years ago on Wednesday October 26, 2011 | Permalink
  3. Thanks for educating me!

    That worked perfectly. Thanks, you guys are great.

    Posted 13 years ago on Thursday October 27, 2011 | Permalink
  4. Thanks for the update jnj.

    Posted 13 years ago on Thursday October 27, 2011 | Permalink

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