Last active
September 6, 2016 19:48
-
-
Save phillipwilhelm/3f7edc44ee02aa8fe616a05fc4594879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// GWS TABLE FILTER | |
// CREDIT: http://pastebin.com/u6yN846V | |
// usage: [gwstable form=17 field=1 value='Workshop A' return=2] using numeric IDs | |
add_shortcode('gwstable', 'gws_tablefilter'); | |
function gws_tablefilter($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) | |
$FILTERENTRIES = 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 ($FILTERENTRIES as $TABLEDATA) { | |
// if the $value passed in matches the value stored in the field you passed in, add it to the output | |
if ($value == $TABLEDATA[$field]){ | |
$output .= '<tr><td width="50px">'. $TABLEDATA[$return] . '</td><td width="20%">' . $TABLEDATA['24'] . '</td><td width="20%">' . $TABLEDATA['23'] . '</td><td width="25%">' . $TABLEDATA['3'] . '</td></tr>'; | |
// $output .= '<tr><td width="100px">'. $TABLEDATA[$return] . '</td><td width="20%">' . $TABLEDATA['24'] . '</td><td width="20%">' . $TABLEDATA['23'] . '</td><td width="25%">' . $TABLEDATA[$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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment