BP Profile Search › Filter s2member custom directory
-
AuthorPost
-
Chris
GuestHey there,
I’m trying to filter a custom directory so that it only shows and can only search s2Members. Through the code below in the custom member loop (full details here), I’ve managed to restrict the directory to only these members, but I can’t get it to filter the search results within this group.
<?php $args = array ( 'role' => 's2member_level1', 'fields' => array( 'id' ) ); // The User Query $user_query = new WP_User_Query( $args ); $artneeds_ids = ''; for($i = 0;$i < sizeof($user_query->results); $i++){ $a = $user_query->results[$i]->id; $artneeds_ids .= $a.","; } ?> <?php if ( bp_has_members(bp_ajax_querystring( 'members' ) . '&type=latest&' . 'include='.$artneeds_ids ) ) : ?>Do you know of any way to do this with BP Profile Search? Alternatively, is there an effective way to make separate pages that each filter by 1-2 xprofile fields?
andrea
Plugin AuthorHi Chris,
If you restrict your Members directory to show only some members, any BP Profile Search form using that directory as a results page will be automatically restricted to those members.
If that doesn’t happen, I’m available to debug the issue, but I’ll need to access your development site.
andrea
Plugin AuthorHi Chris,
I was able to reproduce the problem you reported. I’m not sure if I can fix it on BP Profile Search, but if you wish you can adapt your code to make it work.
The reason is that BP Profile Search filters
bp_ajax_querystringand anything you put outside that function isn’t filtered.To make things work, you can filter
bp_ajax_querystringtoo. An example is in this code:https://gist.github.com/sbrajesh/5904292
that modifies
$args['exclude'], while you should set$args['include'] = $artneeds_ids;instead.
-
AuthorPost