[buddypress-trac] [BuddyPress Trac] #5763: Friends core widget: remove the echo

buddypress-trac noreply at wordpress.org
Fri Jul 18 18:37:20 UTC 2014


#5763: Friends core widget: remove the echo
-----------------------------------------+------------------------------
 Reporter:  danbp                        |       Owner:
     Type:  task                         |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Friends                      |     Version:  2.0
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |
-----------------------------------------+------------------------------

Comment (by danbp):

 here what i did with ajax function.


 {{{

 {{{
 function bpfr_custom_core_ajax_widget_friends() {
         remove_action( 'wp_ajax_widget_friends',
 'bp_core_ajax_widget_friends' );
         remove_action( 'wp_ajax_nopriv_widget_friends',
 'bp_core_ajax_widget_friends' );

         check_ajax_referer( 'bp_core_widget_friends' );

         switch ( $_POST['filter'] ) {
                 case 'newest-friends':
                 $type = 'newest';
                 break;

                 case 'recently-active-friends':
                 $type = 'active';
                 break;

                 case 'popular-friends':
                 $type = 'popular';
                 break;
         }

         $members_args = array(
         'user_id'         => bp_displayed_user_id(),
         'type'            => $type,
         'max'             => absint( $_POST['max-friends'] ),
         'populate_extras' => 1,
         );

 if ( bp_has_members( $members_args ) ) : ?>
 <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. NE PAS
 RETIRER ?>

 <?php // ajout de la condition pour exclure l'admin

         while ( bp_members() ) : bp_the_member();
         $exclude_ids = array(1); /* member ids separated by comma to
 exclude from listing */
         if (!in_array(bp_get_member_user_id(), $exclude_ids)) {
         ?>


         <li class="vcard">
                 <div class="item-avatar">
                         <a href="<?php bp_member_permalink() ?>"><?php
 bp_member_avatar() ?></a>
                 </div>

                 <div class="item">
                         <div class="item-title fn"><a href="<?php
 bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php
 bp_member_name() ?></a></div>
                         <?php if ( 'active' == $type ) : ?>
                         <div class="item-meta"><span
 class="activity"><?php bp_member_last_active() ?></span></div>
                         <?php elseif ( 'newest' == $type ) : ?>
                         <div class="item-meta"><span
 class="activity"><?php bp_member_registered() ?></span></div>
                         <?php elseif ( bp_is_active( 'friends' ) ) : ?>
                         <div class="item-meta"><span
 class="activity"><?php bp_member_total_friend_count() ?></span></div>
                         <?php endif; ?>
                 </div>
         </li>

 <?php } endwhile; ?>

 <?php else: ?>
 <?php echo "-1[[SPLIT]]<li>"; // ne pas retirer !?>
 <?php _e( 'There were no members found, please try another filter.',
 'buddypress' ) ?>
 <?php echo "</li>"; ?>
 <?php endif;
 }
 add_action( 'wp_ajax_widget_friends',
 'bpfr_custom_core_ajax_widget_friends' );
 add_action( 'wp_ajax_nopriv_widget_friends',
 'bpfr_custom_core_ajax_widget_friends' );
 }}}

 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5763#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list