[buddypress-trac] [BuddyPress Trac] #6801: Filtering custom activity pages with parse_args

buddypress-trac noreply at wordpress.org
Fri Jan 1 09:16:37 UTC 2016


#6801: Filtering custom activity pages with parse_args
--------------------------+-----------------------------
 Reporter:  snd26         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  API           |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 There is a bug when using WordPress page conditionals such as is_page
 ('custom-page') inside the bp_after_has_activities_parse_args filter to
 filter activities. They start filtering OK, but when the load more button
 is clicked, the next items are not getting filtered. I've done some tests
 and it seems to be because of the way bp-templates/bp-
 legacy/js/buddypress.js uses ajax to load more activities.

 Here is what I've done.

 I'm creating custom activity pages by setting them up in admin>pages>add
 page 'custom-page-1', 'custom-page-2' etc. I've setup custom activity
 pages similar to the activity/index.php to create the activity loop:


 {{{
 <div id="buddypress">
      <div class="activity">
           <?php bp_get_template_part( 'activity/activity-loop' ); ?>
      </div>
 </div>
 }}}



 Now with the parse_args filter, here is an example to show you what is
 working and what is not (using the per_page filter for demonstration):


 {{{
 function cm_activity_filter( $retval ) {

         // The following conditionals to filter are working OK:

         // Activity directory
         if ( bp_is_activity_directory() ) {
              $retval['per_page'] = 2;
         }

         // User profile just-me component
         if ( bp_is_current_action( 'just-me' )) {
              $retval['per_page'] = 3;
         }

         // A custom component in the members profile I setup using
 bp_core_new_nav_item
          if ( bp_is_current_action( 'custom-compenent' )) {
               $retval['per_page'] = 4;
         }



         /* Bug: The following conditionals start off filtering OK, but
         when the load more button is clicked, the new items are not
 filtering: */

         // custom activity page 1
         if ( is_page( 'custom-page-1' ) ) {
              $retval['per_page'] = 5;
         }

         /* search page
          *
          * I also have a search page for the activities & members - I use
 the WorPress
          * search box and setup the activity loop & member loop in
 'search.php'.
          */
         if ( is_search() ) {
              $retval['per_page'] = 2;
         }



         return $retval;
 }
 add_filter( 'bp_after_has_activities_parse_args', 'cm_activity_filter' );
 }}}



 Note: I don't have this problem using WordPress page conditionals to
 filter my custom member pages with bp_after_has_members_parse_args filter,
 it is just when filtering my custom activity pages.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6801>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list