Created
May 13, 2019 14:11
-
-
Save gogrw/666d17105e99b9f98a2bbe2697a8f343 to your computer and use it in GitHub Desktop.
Shortcode for Listing Users from Meta Data - Without Parameters
This file contains hidden or 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
/** | |
* Shortcode for Listing Users from Meta Data on PDF REPORT | |
* Usage: [list_users_pdf] | |
*/ | |
function pdf_users_from_meta() { | |
$user_query = new WP_User_Query( array( | |
'meta_key' => '{report_type:3}', | |
'meta_value' => '{which_report:1}', | |
'role__in' => wp_parse_list( '{which_state:2:value}' ), | |
) ); | |
$users = $user_query->get_results(); | |
if (!empty($users)) { | |
$results = '<table class=list_user_table> | |
<tr> | |
<td class=list_user_title1>Shop #</td> | |
<td class=list_user_title2>City</td> | |
<td class=list_user_title3>State</td> | |
<td class=list_user_title4>Franchisee</td> | |
<td class=list_user_title5>Consultant</td> | |
</tr>'; | |
foreach ($users as $user){ | |
$results .= '<tr> | |
<td class=list_user_td_left>' . $user->Store_Number . '</a></td> | |
<td class=list_user_td>' . $user->City . '</td> | |
<td class=list_user_td>' . $user->State . '</td> | |
<td class=list_user_td>' . $user->display_name . '</td> | |
<td class=list_user_td>' . $user->Group . '</td> | |
</tr>'; | |
} | |
$results .= '</table>'; | |
} else { | |
$results = 'No users found'; | |
} | |
wp_reset_postdata(); | |
return $results; | |
} | |
add_shortcode( 'list_users_pdf', 'pdf_users_from_meta' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment