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:
- 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?
- 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);