function wpb_random_users() {
global $wpdb;
$randomusers = '<div class="grid-container">';
// Query database for users
$usernames = $wpdb->get_results("SELECT display_name, user_url, user_email, ID FROM $wpdb->users ORDER BY RAND() LIMIT 4");
// Display users in a list
foreach ($usernames as $username) {
// $usr_ID = $username->ID;
if (!$username->user_url) :
$randomusers .= '<grid-item>' .get_avatar($username->user_email, 45) .$username->display_name.get_user_meta( $username->ID, 'dbt_functie', true );"</grid-item>";
else :
$randomusers .= 'li' .get_avatar($username->user_email, 45).'<a href="'.$username->user_url.'">'.$username->display_name."</a>/li";
endif;
}
$randomusers .= '</div>';
return $randomusers;
}
add_shortcode('randomusers','wpb_random_users');