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