Skip to content

Instantly share code, notes, and snippets.

@itthinx
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itthinx/0c8da0fee5662a87f12c to your computer and use it in GitHub Desktop.
Save itthinx/0c8da0fee5662a87f12c to your computer and use it in GitHub Desktop.
[list_group_users]
<?php
add_shortcode( 'list_group_users', 'list_group_users' );
function list_group_users( $atts, $content = '' ) {
$output = '';
if ( isset( $atts['group'] ) ) {
if ( $group = Groups_Group::read_by_name( trim( $atts['group'] ) ) ) {
$group = new Groups_Group( $group->group_id );
$groups_users = $group->users;
usort( $groups_users, 'sort_list_group_users' );
if ( !empty( $groups_users ) ) {
$output .= '<ul>';
foreach ( $groups_users as $groups_user ) {
$output .= '<li>' . wp_strip_all_tags( $groups_user->user->user_login ) . '</li>';
}
$output .= '</ul>';
}
}
}
return $output;
}
function sort_list_group_users( $u1, $u2 ) {
return strcmp( $u1->user->user_login, $u2->user->user_login );
}
@itthinx
Copy link
Author

itthinx commented Jul 23, 2014

Copy the file to your active theme's root folder and in its functions.php add this line at the end:

include_once 'list-group-users.php';

Example shortcode usage:

[list_group_users group="Registered"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment