I have in the database a table with the user_id
and corresponding group_id
values, so each row contain the ID of the user that is a member of a group and the related group ID. The question is: How to display the names of users from a specific group, plus some metadata, with a shortcode, for example [group_members group_id=1]
? With the bellow function, that I try to adapt for this without success, I can to display only the user ID or the group ID.
add_shortcode( 'group_members', 'group_members_shortcode_handler' );
function group_members_shortcode_handler ( $atts, $content = null ) {
global $wpdb;
$querystr = "SELECT * FROM wp_groups_user_group";
$users = $wpdb->get_results($querystr, OBJECT);
foreach ($users as $user) {
$output .= $user->group_id;
}
return $output;
}
wp_groups_user_group
), columns names (user_id
andgroup_id
). This is not enough?$wpdb
.