Sorting by xprofile field
-
Hi everyone. I’m kind of lost on how to sort by an xprofile field. My code is below which works fine on listing the appropriate members for each group. The groups being “Executive Board” and “Steering Committee”.
I have tried adding the “type=”alphabetical”, however that doesn’t give any of the correct results. Instead it seems to list only a few of the members who are not even in the same group.
My code is below:
<?php /* Template Name: Buddypress Leadership Template */ ?> <?php get_header(); ?> <?php if ( bp_has_members() ) : ?> <h4 id="executive-header">Executive Board</h4> <div class="leadership-list"> <ul class="members-list executives leadership item-list" role="main"> <?php while ( bp_members() ) : bp_the_member(); ?> <?php global $current_site; $user_id = bp_get_member_user_id(); $memberOf = xprofile_get_field_data( 'Member of' ,bp_get_member_user_id(), $multi_format = 'array'); $jobTitle = xprofile_get_field_data( 'Job Title' ,bp_get_member_user_id()); $companyName = xprofile_get_field_data( 'Company' ,bp_get_member_user_id()); $lastName = xprofile_get_field_data( 'Last Name' ,bp_get_member_user_id()); if ($memberOf != '') { foreach($memberOf as $key => $value){ ?> <?php if($value == "Executive Board") {?> <li class="member-dir-member"> <div class="column-first"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> </div> <!-- end column-first --> <div class="column"> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>" class="member-name"><?php bp_member_name(); ?> <?php echo $lastName ?></a> <div class="job-title"> <?php echo $jobTitle; ?> of </div> <div class="company-name"> <?php echo $companyName ?></div> </div> </div> </div> <!-- end column --> <div class="clear"></div> </li> <?php } ?> <?php } } endwhile; ?> </ul> </div> <h4 id="steering-header">Steering Committee</h4> <div class="leadership-list"> <ul class="members-list executives leadership item-list" role="main"> <?php while ( bp_members() ) : bp_the_member(); ?> <?php global $current_site; $user_id = bp_get_member_user_id(); $memberOf = xprofile_get_field_data( 'Member of' ,bp_get_member_user_id(), $multi_format = 'array'); $jobTitle = xprofile_get_field_data( 'Job Title' ,bp_get_member_user_id()); $companyName = xprofile_get_field_data( 'Company' ,bp_get_member_user_id()); $lastName = xprofile_get_field_data( 'Last Name' ,bp_get_member_user_id()); if ($memberOf != '') { foreach($memberOf as $key => $value){ ?> <?php if($value == "Steering Committee") {?> <li class="member-dir-member"> <div class="column-first"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> </div> <!-- end column-first --> <div class="column"> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>" class="member-name"><?php bp_member_name(); ?> <?php echo $lastName ?></a> <div class="job-title"> <?php echo $jobTitle; ?> of </div> <div class="company-name"> <?php echo $companyName ?></div> </div> </div> </div> <!-- end column --> <div class="clear"></div> </li> <?php } ?> <?php } } endwhile; ?> </ul> </div> <?php do_action( 'bp_after_directory_members_list' ); ?> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> <?php get_footer(); ?>
Any and all help is appreciated
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Sorting by xprofile field’ is closed to new replies.