bp_friends_random_members( int $total_members = 5 )
Pull up a group of random members, and display some profile data about them.
Description
This function is no longer used by BuddyPress core.
Parameters
- $total_members
-
(Optional) The number of members to retrieve.
Default value: 5
Source
File: bp-friends/bp-friends-template.php
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | function bp_friends_random_members( $total_members = 5 ) { if ( ! $user_ids = wp_cache_get( 'friends_random_users' , 'bp' ) ) { $user_ids = BP_Core_User::get_users( 'random' , $total_members ); wp_cache_set( 'friends_random_users' , $user_ids , 'bp' ); } ?> <?php if ( $user_ids [ 'users' ] ) { ?> <ul class = "item-list" id= "random-members-list" > <?php for ( $i = 0, $count = count ( $user_ids [ 'users' ] ); $i < $count ; ++ $i ) { ?> <li> <a href= "<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->id ) ?>" ><?php echo bp_core_fetch_avatar( array ( 'item_id' => $user_ids [ 'users' ][ $i ]->id, 'type' => 'thumb' ) ) ?></a> <h5><?php echo bp_core_get_userlink( $user_ids [ 'users' ][ $i ]->id ) ?></h5> <?php if ( bp_is_active( 'xprofile' ) ) { ?> <?php $random_data = xprofile_get_random_profile_data( $user_ids [ 'users' ][ $i ]->id, true ); ?> <div class = "profile-data" > <p class = "field-name" ><?php echo $random_data [0]->name ?></p> <?php echo $random_data [0]->value ?> </div> <?php } ?> <div class = "action" > <?php if ( bp_is_active( 'friends' ) ) { ?> <?php bp_add_friend_button( $user_ids [ 'users' ][ $i ]->id ) ?> <?php } ?> </div> </li> <?php } ?> </ul> <?php } else { ?> <div id= "message" class = "info" > <p><?php _e( "There aren't enough site members to show a random sample just yet." , 'buddyboss' ) ?></p> </div> <?php } ?> <?php } |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.