<?php
// http://www.gravityhelp.com/forums/topic/query-submitted-forms-from-custom-page#post-39607
// create shortcode to return names of participants for a specific form
// usage: [participants form=37] where 37 is the form ID
add_shortcode('participants', 'troop24_participants');
function troop24_participants($atts) {
$form_id = $atts['form'];
// function to pull entries from one form
$scouts = RGFormsModel::get_leads($form_id, '1.6', 'ASC');
$html = "<ul class='participants'>\n";
// loop through all the returned results
foreach ($scouts as $participant) {
// field 1.3 is the first name. I upper cased the first letter for consistency
$fname = ucfirst($participant['1.3']);
// I wanted to show only the first initial of the last name, also upper case
$linitial = strtoupper(substr($participant['1.6'],0,1));
$html .= "\t<li>$fname $linitial</li>\n";
}
$html .= '</ul>';
// return the html output from the shorcode
return $html;
}