[buddypress-trac] [BuddyPress Trac] #5823: bp_ajax_querystring('members') does not work with exclude

buddypress-trac noreply at wordpress.org
Tue Aug 19 17:51:05 UTC 2014


#5823: bp_ajax_querystring('members') does not work with exclude
--------------------------+-----------------------------
 Reporter:  weirdpress    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Members       |    Version:  2.0
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 hiya :)

 i am running into issues using the bp_ajax_querystring filter.

 I omitted some of the if conditions and did not add the function that
 concatenates the user ids i get from the database since they are not part
 of the problem,
 the issue arises as soon as i replace the {{{$args['include']}}} with
 {{{$args['exclude']}}}, at which point the members list includes all
 members again.
 Since i have way more members to include (around 1700) than i have to
 exclude (around 300) i would love to turn this around.

 tracked this down through:
 bp-members-template.php: bp_has_members -> BP_Core_Members_Template
 bp-members-functions.php: bp_core_get_users
 bp-core-classes.php: BP_User_Query

 and the problem shows itself here, line 333 of bp-core-classes.php:
 {{{#!php
     print_r($include);
     $include     = false !== $include ? wp_parse_id_list( $include ) :
 array();
     $include_ids = $this->get_include_ids( $include );
     if ( ! empty( $include_ids ) ) {
         $include_ids    = implode( ',', wp_parse_id_list( $include_ids )
 );
         $sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})";
     }

     // 'exclude' - User ids to exclude from the results
     print_r($exclude);
     if ( false !== $exclude ) {
         $exclude_ids    = implode( ',', wp_parse_id_list( $exclude ) );
         $sql['where'][] = "u.{$this->uid_name} NOT IN ({$exclude_ids})";
     }
 }}}
 if i pass include to the args, then i get all the include ids in that
 print_r,
 if i pass exclude i only get one id.

 i will definitely track this down further through the files referenced
 above,
 but right now i don't have the time so i figured i would throw this into
 trac.


 {{{#!php

 private function __construct() {
     add_filter( 'bp_ajax_querystring', array($this, 'bp_include_users'),
 20, 2);
 }

 public function bp_include_users( $qs=false, $object=false ) {
     // hide for members page OR if searching for friends
     if($object !== 'members' || ! empty($args['user_id']))
         return $qs;

     //list of users to exclude
     $x_users = '1,2,3,4,5,6';
     //get the existing args if there are any
     $args = wp_parse_args($qs);

     //including works
     $args['include'] = $x_users;

     //excluding does not
     //$args['exclude'] = $x_users;

     return build_query($args);
 }
 }}}

 thanks for everything, buddypress is awesome :)
 greetings
 j.

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


More information about the buddypress-trac mailing list