Is it only alphabetical that does that?
‘Last Active’ shouldn’t.
What about ‘Newest Registered’ ?
Alphabetical sorts against the display_name field in the wp_users table, so you might have to write a filter.
How many BP users do you have?
Thanks for the prompt response, Shane.
Yes, only the alphabetical sort displays all MS users. The issue is that the BP site is a private Board of Directors site, while the other sites are maintained by users that are employees and have no business showing up as members of the private BP site.
There are only 12 board members that are BP users vs. 100+ employee users for the other sites.
Any idea of how to write the filter?
🙂 Eric
This will get you started re filter:
function ericreynolds007_filter_ajax_querystring( $querystring = '', $object = '' ) {
if( $object != 'members' )
return $querystring;
$defaults = array(
'type' => 'active',
'action' => 'active',
'scope' => 'all',
'page' => 1,
'user_id' => 0,
'search_terms' => '',
'exclude' => false,
);
$dtj_querystring = wp_parse_args( $querystring, $defaults );
if( $dtj_querystring['type'] == 'alphabetical' ) {
$users = get_users('role=editor');
$users_str = '';
foreach ( $users as $user ) {
$users_str .= $user->ID . ',';
}
$users_str = rtrim($users_str, ",");
$dtj_querystring['include'] = $users_str;
return $dtj_querystring;
}
else
return $querystring;
}
add_filter( 'bp_ajax_querystring', 'ericreynolds007_filter_ajax_querystring', 20, 2 );
The key parts are the ‘include’ which restricts the query to those users.
This example gathers all users with role=editor.
You’ll have to figure out how to collect the ids of the board members.
You might try using the ‘type’ field in the bp_activity table.
SELECT user_id FROM .... WHERE type = 'last_activity'
Thanks so much Shane. I really appreciate it. 🙂
Thank you Shane. I was facing same difficulty. Your help is really appreciated.
Hi Shane, I’ve gone a different route, hoping to avoid adding user IDs everytime a new Board Member joins the BP site.
From a support request, I discovered that I could exclude or include roles to display in the members loop by adding the following code to the members-loop.php. For the private BP site, using the Members plugin, I created a new role, “bod_member” and reassigned the few members this role. I then added the following code to include only the bod_member…
<?php while ( bp_members() ) : bp_the_member();
$user = new WP_User( bp_get_member_user_id() );
if ( $user->roles[0] == 'bod_member' ) :
?>
Unfortunately, upon saving the file, the site returned a parse error, referencing the code below:
<?php endwhile; ?>
The error begins with “Parse error: syntax error, unexpected ‘endwhile'”
Am I doing something wrong?
🙂 Eric
Try adding this just above the endwhile
<?php endif; ?>
btw – this isn’t the proper forum for basic php coding questions.
Fantastic! That did it. I apologize for posting in the wrong forum.
🙂 Eric