[Resolved] Using BP_User_Query
-
Hi there
I’m trying to use the BP_User_Query class to filter my members on the member loop. It appears to have successfully filtered them, but once I click on either the “All Members” button, or try to search for members, the query seems to drop and it once more returns all of the members again. Here is my code
class BP_Custom_User_Ids { private $custom_ids = array(); public function __construct() { $this->custom_ids = $this->get_custom_ids(); add_action( 'bp_pre_user_query_construct', array( $this, 'custom_members_query' ), 1, 1 ); add_filter( 'bp_get_total_member_count', array( $this, 'custom_members_count' ), 1, 1 ); } private function get_custom_ids() { $custom_id = wp_get_current_user(); $custom_id = $custom_id->ID; return $custom_id; } function custom_members_query( $query_array ) { $query_array->query_vars['include'] = $this->custom_ids; //in case there are other items like widgets using the members loop on the members page remove_action( 'bp_pre_user_query_construct', array( $this, 'custom_members_query' ), 1, 1 ); } function custom_members_count ( $count ) { $new_count = count( $this->custom_ids ); return $new_count; } } function custom_user_ids() { new BP_Custom_User_Ids (); } add_action( 'bp_before_directory_members', 'custom_user_ids' );
Are there more action/filter hooks that need to be added to my construct?
Thanks in advance
George.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[Resolved] Using BP_User_Query’ is closed to new replies.