Last active
August 29, 2015 14:04
-
-
Save itthinx/0c8da0fee5662a87f12c to your computer and use it in GitHub Desktop.
[list_group_users]
This file contains 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
<?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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"]