Advertisement
valuser

List of Local Members on Multi-Network

Jul 5th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.76 KB | None | 0 0
  1. /* Get local members with bp-multi-network & Networks+   first-attempt*/
  2.  
  3. /* On each Network make a  New Page - /local-members/  */
  4.  
  5. /* On each Network Have a pre-filled required registration field (Local-Place) (1 item default - New York in New York Network, Vancouver in Vancouver Network etc etc) */
  6.  
  7. /* Put code below on lines 21 to line 120 on New Page in each Network /local-members/. Change line 24 to suit each Network */
  8.  
  9. /* Put code below on lines 127 to 152 in functions.php */
  10.  
  11. /* Please report back to forum with any suggestions */
  12. /*I'd imagine that there is a better way!*/
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. <?php do_action( 'bp_before_members_loop' ); ?>
  22. <hl><?php  $avar = "This a list of local members"; echo $avar."<br/>"; ?></hl>
  23. <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
  24. <?php if (bp_has_members( array( 'include' => include_by_meta('New York', 'Local-Place'), 'type' => 'newest') )) : ?>
  25.     <div id="pag-top" class="pagination">
  26.  
  27.         <div class="pag-count" id="member-dir-count-top">
  28.  
  29.             <?php bp_members_pagination_count(); ?>
  30.  
  31.         </div>
  32.  
  33.         <div class="pagination-links" id="member-dir-pag-top">
  34.  
  35.             <?php bp_members_pagination_links(); ?>
  36.  
  37.         </div>
  38.  
  39.     </div>
  40.  
  41.     <?php do_action( 'bp_before_directory_members_list' ); ?>
  42.  
  43.     <ul id="members-list" class="item-list" role="main">
  44.     <?php while ( bp_members() ) : bp_the_member(); ?>
  45.  
  46.  
  47.         <li>
  48.             <div class="item-avatar">
  49.                 <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
  50.             </div>
  51.  
  52.             <div class="item">
  53.                 <div class="item-title">
  54.                     <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
  55.  
  56.                     <?php if ( bp_get_member_latest_update() ) : ?>
  57.  
  58.                         <span class="update"> <?php bp_member_latest_update(); ?></span>
  59.  
  60.                     <?php endif; ?>
  61.  
  62.                 </div>
  63.  
  64.                 <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div>
  65.  
  66.                 <?php do_action( 'bp_directory_members_item' ); ?>
  67.  
  68.                 <?php
  69.                  /***
  70.                   * If you want to show specific profile fields here you can,
  71.                   * but it'll add an extra query for each member in the loop
  72.                   * (only one regardless of the number of fields you show):
  73.                   *
  74.                   * bp_member_profile_data( 'field=the field name' );
  75.                   */
  76.                 ?>
  77.             </div>
  78.  
  79.             <div class="action">
  80.  
  81.                 <?php do_action( 'bp_directory_members_actions' ); ?>
  82.  
  83.             </div>
  84.  
  85.             <div class="clear"></div>
  86.         </li>
  87.  
  88.     <?php endwhile; ?>
  89. <?php endif; ?>
  90.     </ul>
  91.  
  92.     <?php do_action( 'bp_after_directory_members_list' ); ?>
  93.  
  94.     <?php bp_member_hidden_fields(); ?>
  95.  
  96.     <div id="pag-bottom" class="pagination">
  97.  
  98.         <div class="pag-count" id="member-dir-count-bottom">
  99.  
  100.             <?php bp_members_pagination_count(); ?>
  101.  
  102.         </div>
  103.  
  104.         <div class="pagination-links" id="member-dir-pag-bottom">
  105.  
  106.             <?php bp_members_pagination_links(); ?>
  107.  
  108.         </div>
  109.  
  110.     </div>
  111.  
  112. <?php else: ?>
  113.  
  114.     <div id="message" class="info">
  115.         <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
  116.     </div>
  117.  
  118. <?php endif; ?>
  119.  
  120. <?php do_action( 'bp_after_members_loop' ); ?>
  121.  
  122.  
  123.  
  124.  
  125. /* add these functions to get local members*/
  126.  
  127. function include_by_meta($theMetaValue, $theMetaField) {
  128.  
  129.     $memberArray = array();
  130. global $members_template;
  131.         if (bp_has_members()) :
  132.         while (bp_members()) :
  133.             bp_the_member();
  134.             $theFieldValue = bp_get_member_profile_data( 'field='. $theMetaField );
  135.             if ($theFieldValue==$theMetaValue) {
  136.                 array_push($memberArray, bp_get_member_user_id());
  137.             }
  138.         endwhile;
  139.         endif;
  140.    
  141.     $theIncludeString=implode(",",$memberArray);
  142.    
  143.     return $theIncludeString;
  144. }
  145.  
  146.  
  147. function localplace() {
  148.   $data = bp_get_member_profile_data( 'field=Local-Place' );
  149.   if ( $data )
  150.     echo "<span>&nbsp;&nbsp;&nbsp;Local Place: $data </span>";
  151. }
  152. add_action( 'bp_directory_members_item', 'localplace' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement