Advertisement
chrishajer

shortcode to pull email addresses from one form

Dec 10th, 2011
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. // http://www.gravityhelp.com/forums/topic/collecting-email-addresses
  2. // shortcode usage: [submitted_emails form='FORMID']
  3. add_shortcode('submitted_emails', 'retrieve_emails');
  4. function retrieve_emails($emails) {
  5.         $form_id = $emails['form'];
  6.     // get all the field values for one form and one field ID
  7.         $addresses = RGFormsModel::get_leads($form_id, 'CHANGE THIS TO YOUR EMAIL FIELD ID', 'ASC');
  8.     // initialize the HTML we are going to return
  9.         $html = "<ul class='email_addresses'>\n";
  10.     // loop through all the leads
  11.         foreach ($addresses as $email) {
  12.                 $html .= "\t<li>$email</li>\n";
  13.         }
  14.         $html .= '</ul>';
  15.     // return the list
  16.         return $html;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement