Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // usage: [workshop form=17 field=1 value='Workshop A' return=2] using numeric IDs
- add_shortcode('workshop', 'total_attendees');
- function total_attendees($atts) {
- extract(shortcode_atts(array(
- // set defaults
- 'form' => '403',
- 'field' => '1',
- 'value' => 'Workshop A',
- 'return' => '2',
- ), $atts));
- // function to pull all the entries from one form
- // get_leads($form_id, $sort_field_number=0, $sort_direction='DESC', $search='', $offset=0,
- // $page_size=30, $star=null, $read=null, $is_numeric_sort = false, $start_date=null,
- // $end_date=null, $status='active', $payment_status = false)
- $attendees = RGFormsModel::get_leads($form, $return, 'ASC', '', 0, 999, NULL, NULL, FALSE, NULL, NULL, 'active', FALSE);
- // initialize an empty output string
- $output = '<table width="100%">';
- // loop through all the returned results
- foreach ($attendees as $attendee) {
- // if the $value passed in matches the value stored in the field you passed in, add it to the output
- if ($value == $attendee[$field]){
- $output .= '<tr><td width="35%">'. $attendee[$return] . '</td><td width="20%">Age: ' . $attendee['3'] . '</td><td width="45%">' . $attendee[$field] . '</td></tr>';
- }
- }
- // do some formatting and return the output from the shortcode
- $output .= '</table>';
- // just the string above will be returned.
- // You can style it here or where you are using the shortcode
- return $output;
- }
- // needed for the above to process the guests list shortcode in sidebar widget
- add_filter('widget_text', 'do_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement