• Resolved jibbius

    (@jibbius)


    BUG:
    On my BuddyPress Members directory, I want to exclude non-approved users.
    I also want to exclude other types of users.

    The current version of the plugin already uses bp_registration_hide_widget_members() to filter out the non-approved users. (Yay!)

    The problem, is that if – earlier in the code – I attempt to exclude some other users also… then this instruction gets overridden.

    For example, if my theme’s member loop looked like this:

    <?php
    /**
     * BuddyPress - Members Loop
     */
    ?>
    <?php do_action('bp_before_members_loop'); ?>
    <?php if (bp_has_members(array('exclude'=>'1,2,3,4,5,6,7,8'))) : ?>

    Then, the instruction to exclude users 1-8 would be ignored (as when BP Reg Options is filtering out the non-approved users, the instruction is overridden).

    BUGFIX:
    The following code change (to /bp-registration-options/includes/core.php) fixes the issue:

    function bp_registration_hide_widget_members( $r = array() ) {
    	$exclude_me = bp_registration_get_pending_users();
    	$excluded = array();
    
    	foreach( $exclude_me as $exclude ) {
    		$excluded[] = $exclude->user_id;
    	}
    	if(!isset($r['exclude'])){
    		$r['exclude'] = implode( ',', $excluded );
    	}else {   // ADDED
    		$r['exclude'] .= ','.implode( ',', $excluded );
    	}
    
    	return $r;
    }

    https://www.ads-software.com/plugins/bp-registration-options/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bugfix: Unable to hide additional users from member loop’ is closed to new replies.