Responsive WordPress Theme – Caliber

A theme with simple controls and limitless potential. Work fast and build an amazing website!   Find out more »

UpThemes – Beautiful WordPress Themes

Create a site your church, gallery, newspaper, blog, recipes, band and more!   See the themes »

Need a little help?  Find answers quickly by searching the forum.
Group Admins
  • jeffw
  • andy

Support for: Mingle – Multi-purpose WordPress Theme

Mingle (WordPress)

Public Group  |  active 7 months ago ago
Viewing post 1 to 6 (6 total posts)

(solved) Members loop

  • greenbrook

    said

    Hi guys

    Does anyone know how to create a separate members loop?

    I have created a hand full of profile fields in the BuddyPress menu and they display really nicely under each profile… but now I would like to display a separate loop that only shows the profile name and a few defined fields. This would work as an address list, but I can not figure out how.

    Have searched BuddyPress forums as well…

    Can anyone lead me in the right direction?

  • greenbrook

    said

    Aha! Got it!

    I have spent a half day wrestling with just this and just after posting in here, I found the solution!
    Sometimes al you need to do is ask ;o)

  • andy

    said

    @Peevdtee

    I’m not sure what solution @greenbrook found. I have not had the occasion to do this myself so I don’t know what it requires. I will see if I can get more information for you or possibly grenbrook can post his solution.

  • greenbrook

    said

    Hi guys

    Sorry for the delay… we had Guy Fawke’s night here in England.

    Initially I would like to display a list of all members showing the contact details they filled in during their registration. I thought a custom BuddyPress page, such as the ‘Groups’ or ‘Friends’ page, would solve this the easiest, but just after posting in here, it occurred to me that all I needed was a page template that called a loop similar to that of the members page.

    1) Duplicate ‘template-bp-template’ and ‘members-loop’ to something like ‘template-bp-address’ and ‘members-loop-address’. In the new template call the new loop in line 54. It could be:
    <?php locate_template( array( 'address/members-loop-address' ), true ) ?>

    And please remember to add this to the very top, so you can choose it from the page editor:
    <?php
    /* Template Name: Address */
    get_header(); ?>

    2) Then custom fit your new loop. I used something like:
    <ul id="members-list" class="item-list">
      <?php while ( bp_members() ) : bp_the_member(); ?>
    <li><div class="address-item">
    <table border="0px" cellpadding="0px" width="100%"><tbody><tr>
    <td width="23%" valign="top"><a href="<?php bp_member_permalink() ?>"><?php bp_member_name() ?></a></td>
    <td width="10%" valign="top"><?php bp_member_profile_data( 'field=Phone' );?></td>
    <td width="20%" valign="top"><?php bp_member_profile_data( 'field=Email' );?></td>
    <td width="10%" valign="top"><?php bp_member_profile_data( 'field=Zip' );?></td>
    <td width="37%" valign="top"><?php bp_member_profile_data( 'field=Address' );?></td>
    </tr></tbody></table>
    </div><div class="clear"></div></li>
      <?php endwhile; ?>
    </ul>

    Remember to add the exact profile fields in the BuddyPress menu, but that’s it!

    3) To add a link in the existing members loop, just like ‘All members’ or ‘Friends’, paste the following in the members-loop.php in line 22:
    <li><a href="<?php echo bp_root_domain() .'/'. BP_ADDRESS_SLUG ?>">
    <?php _e( 'Address list', 'buddypress' ) ?>
    </a></li>

    Add this snippet to the functions.php:
    define('BP_ADDRESS_SLUG', 'address/');

    And add this to the new loop (e.g. members-loop-address.php) to make it consistent:
    <li><a href="<?php echo bp_root_domain() .'/'. BP_MEMBERS_SLUG ?>">
    <?php _e( 'Members Directory', 'buddypress' ) ?>
    </a></li>

    Does this make sense?

    Cheers

  • andy

    said

    Thanks for sharing that. I’m sure it will be very helpful for others and I can already see how it can be modified for a lot of other uses.

Viewing post 1 to 6 (6 total posts)
Topic tags: Buddypress, Loop, Members loop