Integrating eNewsletter and Gravity Forms -- a Primer

Team WPMU,

One of the most common requests that I've seen for eNewsletter is to integrate it with Gravity Forms. After much research and discussion with GF, I have a 90% solution. It's not perfect, but I'm hoping the staff at WPMU will be able to take it to the next level. Here is what I have:

Based on an earlier thread with Maniu, these are the available "hooks" for eNewsletter:

newsletter_action = 'new_subscribe'
e_newsletter_email =
--optional--
e_newsletter_name =
e_newsletter_groups_id = (array with ids: e_newsletter_groups_id[])

You can take these and create an HTML form for eNewsletter signups. Here is a sample -- I tested it and it worked perfectly:

<form action="http://www.yoursite.com/" method="post">
<input name="newsletter_action" type="hidden" value="new_subscribe" />
<label for="name">Your Name</label>
<input id="name" name="e_newsletter_name" type="text" />
<label for="email">Your Email Address</label>
<input id="email" name="e_newsletter_email" type="text" />
<input type="submit" value="Submit" /></form>

Talking with Gravity Forms, here is how you translate that HTML form into a GF:

1. Add a Hidded field type. In advanced tab put new_subscribe in Default Value.
2. Your Name field should be a single line text field.
3. Email is a email type field.

Then to post it to your third-party service, use the gform_after_submission hook, you can check the example 2 on the following link to see how: http://www.gravityhelp.com/documentation/page/Gform_after_submission

This solution will work for a single instance, but it needs some refinement by someone who knows more than I to make it universal. I'm thinking custom fields in GF, etc, so members will not have to edit their functions.php file every time. Here is a link on adding custom field options to GF: http://wpsmith.net/2011/plugins/how-to-create-a-custom-form-field-in-gravity-forms-with-a-terms-of-service-form-field-example/

I hope this helps jump start this discussion and gives the WPMU dev team a leg up in making the eNewsletter plugin compatible with Gravity Forms.

Thanks,

Rob Mc