Hi,
I added the code to exclude denied and pending users from member directory, listing and forum count. It works fine 2 days before. But now it’s not.
Total memebers are 122 but it shows 119. Even I run the repair tool.
Here is my code
///// Remove pending/denied users from the member directory////////
add_filter( ‘bp_after_has_members_parse_args’, ‘buddydev_exclude_users_by_role’ );
function buddydev_exclude_users_by_role( $args ) {
// do not exclude in admin.
if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) {
return $args;
}
$excluded = isset( $args[‘exclude’] ) ? $args[‘exclude’] : array();
if ( ! is_array( $excluded ) ) {
$excluded = explode( ‘,’, $excluded );
}
$role = ‘subscriber’;// change to the role to be excluded.
$user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );
$excluded = array_merge( $excluded, $user_ids );
$args[‘exclude’] = $excluded;
return $args;
}
/********** Excluded ADmin and pending/denied users from members listing page ***************/
function exclude_total_users($count){
$role = ‘subscriber’;// change to the role to be excluded.
$user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );
$user_excluded = count($user_ids);
return ($count – $user_excluded – 1);
}
add_filter(‘bp_get_total_member_count’,’exclude_total_users’);
/******* Exclude pending/denied and admin users from forum stats ***********/
function exclude_users_forum($user_count){
$role = ‘subscriber’;// change to the role to be excluded.
$user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );
$user_excluded = count($user_ids);
return ($user_count – $user_excluded – 1);
}
add_filter(‘bbp_get_total_users’,’exclude_users_forum’);
/*******************/
Can you help me to sort it out, what is the issue??
Thanks in advance.