Skip to:

Order of members results

  • Martijn



    I need some help with setting the results in a different order.
    On two seperate locations I want to show the profiles with birthdays in different order.

    location 1) I want to show all ‘members’ (I’ll style it in a 3 or 4 column grid), ordered by First name alphabeticly OR by birthdate excluding year. But I think the first option is easier and actually more natural to users.

    From the documentation here I got this code, and took some stuff out and added the birthdate field.
    This code works as in, it displays the members, add a link to the profile and adds the birthdate.
    Now I just need this to be ordered by name alphabeticly.

    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
      <?php do_action( 'bp_before_directory_members_list' ); ?>
      <ul id="members-list" class="item-list" role="main">
      <?php while ( bp_members() ) : bp_the_member(); ?>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>        
      <?php do_action( 'bp_directory_members_item' ); ?>
     <?php echo bp_member_profile_data('field=geboortedatum');?>
           <div class="action">
                <?php do_action( 'bp_directory_members_actions' ); ?>
           <div class="clear"></div>
      <?php endwhile; ?>
      <?php do_action( 'bp_after_directory_members_list' ); ?>
      <?php bp_member_hidden_fields(); ?>
     <?php endif; ?>

    Location 2) Show 5 profiles with the first upcoming birthdays.
    Changing the above code with this:
    if ( bp_has_members( bp_ajax_querystring( 'members' ).'&max=5' ) ) :

    I get to limit the output of only 5 profiles. But I don’t know if this limit is can/will be applied before or after the order.

    I would like to order these on dates after ‘today’

    I now use a datepicker to add birthdate, but could add 2 seperate number fields for day and month, as I guess this will be easier to filter with.

    So I did get some results, but the ordering is something I can’t figure out and would like some help with. I found a plugin before (buddypress birthday widget) but its not working as I would like it to and after earlier contact I have not received any response from the plugin def for some time now, so I’m trying to make something myself.

    Hope someone can point me in the right direction.

    Kind regards,


Viewing 3 replies - 1 through 3 (of 3 total)

  • danbp



    for 1) try
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) . 'type=alphabetical' ) ) : ?>

    For 2) read here perhaps it helps




    For 1)
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) . 'type=alphabetical' ) ) : ?>
    Didn’t work, adding & to '&type=alphabetical' and it works.


    For 2) it is still very hard to grasp what to do here. Might need to find an alternative for here.

    Thanks for the help.

    Kind regards,




    For 2) the idea is to sort users alphabetically by birthdate.

    Members Loop

    The snippets i indicated use a field called contributor. You could try to replace by birthdate, or whatever you named that profile field.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar