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.

Registering users with a Gravity Form

  1. I'm looking to create a form that I'll use to do two things. First I'll set the user up with a WordPress account, and I'll also use an API call to subscribe them to an E-Mail list. This is something that's pretty common on sites that I develop (where they offer a free E-Book or something for signing up for their mailing list). I can do it without Gravity Forms, but I'd like to be able to set it up where they could modify the form.

    Here's the way I usually do it:

    • I have a form that's used in a few places (sidebar, inserted into certain posts, etc).
    • The form submits to something like example.com/signup
    • A script then processes that form, uses an API call to sign them up for the mailing list (which sends them their password for the site as part of the double opt-in E-Mail)
    • Then the user gets a message either saying that it succeeded and they need to check their E-Mail, or an error about what went wrong and the form is displayed again

    Most of this seems pretty easy, but I'm wondering if it's possible to do the following:

    1. Can I filter the form in such a way as to make it fail (as though not validated) and display my error along with re-displaying the form?
    2. Could you add a filter to the is_duplicate that would let me check somewhere else for duplicates? I need to check that the E-Mail is unique among all users. Maybe something like: $count = apply_filters('gform_is_duplicate', $wpdb->get_var($sql), $form_id, $field, $value);
    Posted 15 years ago on Sunday November 1, 2009 | Permalink
  2. There's another thing. It seems that you can't set the "not unique" error message. I'd like to be able to set it as well as be able to add a %s where I want the E-Mail address to show. Something like:
    There is already and account for %s. Please log in or recover your password.

    Posted 15 years ago on Sunday November 1, 2009 | Permalink
  3. Aaron,
    We are wrapping up development on 1.3 and I might be able to add a hook/filter so that you can fail the validation with your message (it currently can't be done). As far as the "not unique" error, it makes sense, but I am not sure it will be a popular enough feature to make it to the UI. I will make sure you can change it via a filter/hook though. I will keep you posted.

    Posted 15 years ago on Monday November 2, 2009 | Permalink
  4. Thanks Alex. I actually modified my version and used that exact code that I pasted in the first post on line 962 in RGFormsModel::is_duplicate() - that line number is based on version 1.2.1. It worked perfectly, allowing me to hook in and check users just like this:

    function noDuplicateEMails($count, $form_id, $field, $value) {
    if ( $form_id == 2 && $field['type'] == 'email' && get_user_by('email', $email) ) {
    $count = 1;
    }
    return $count;
    }
    add_action('gform_is_duplicate', 'noDuplicateEMails', null, 4);

    It works perfectly.

    Posted 15 years ago on Monday November 2, 2009 | Permalink
  5. Aaron,
    I have added the gform_is_duplicate filter to RGFormsModel::is_duplicate(), so you should be good to go when upgrading to 1.3.

    Let me know if you would like to give it a run and I will send it to you.

    Posted 15 years ago on Monday November 9, 2009 | Permalink