jdwired (February 10th, 2014)
/* ========== Get listing by author ID ========== */
function tmm_count_user_listing( $user_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, VA_LISTING_PTYPE ) );
}
/* ========== Display listing author list (Shortcode) ========== */
add_shortcode('author_list', 'author_list');
function author_list() {
$users = get_users('blog_id=1&orderby=nicename&role=subscriber');
$out = '<ul>';
foreach ($users as $user) {
$listings = tmm_count_user_listing($user->ID);
if ($listings) {
echo '<li>' . $user->display_name . ' - ' . $user->user_email . ' - ' . $user->ID . '</li>';
} else {
echo '<li>' . $user->display_name . ' - ' . $user->user_email . ' - ' . $user->ID . ' - <strong>Waste of space!</strong></li>';
}
}
$out .= '</ul>';
return $out;
}
jdwired (February 10th, 2014)
There are currently 1 users browsing this thread. (0 members and 1 guests)