Advertisement
chrishajer

shortcode to pull email addresses from one form

Dec 10th, 2011
895
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement