Viewing 5 replies - 16 through 20 (of 20 total)
  • I finally managed to make it work. Here are my functions if it can help somebody else (it can be easily adapted for your own use) :

    function hide_profile_template() {
    	global $bp;
    
    	/* Prevent access to the moderated users profiles from everyone except the moderated user themselves and the administrators (IDs "1" and "4") */
    	$pending_users = bp_registration_get_pending_users();
    	foreach( $pending_users as $pending_user ) {
    		$pending_user = $pending_user->user_id;
    		if((bp_is_profile && $bp->displayed_user->id == $pending_user && $bp->loggedin_user->id != $pending_user && $bp->loggedin_user->id !=1 && $bp->loggedin_user->id !=4)) :
    			wp_redirect( home_url() );
    			exit;
    		endif;
    	}
    }
    add_action( 'wp', 'hide_profile_template', 1 );
    
    /* hiding moderated users (and admins) on the members listing */
    function bpdev_exclude_users($qs=false,$object=false){
    	// Admins
    	$excluded_user='1,4'; 
    
    	// Moderated users
    	$pending_users = bp_registration_get_pending_users();
    	foreach( $pending_users as $pending_user ) {
    		$pending_user = $pending_user->user_id;
    		$excluded_user .= ',';
    		$excluded_user .= $pending_user;
    	}
    
        if($object != 'members') //hiding from members
        return $qs;
    
        $args=wp_parse_args($qs);
    
        //except for friends
    
        if(!empty($args['user_id']))
        return $qs;	
    
        if(!empty($args['exclude']))
        $args['exclude'] = $args['exclude'].','.$excluded_user;
        else
        $args['exclude'] = $excluded_user;
    
        $qs = build_query($args);
    
        return $qs;
    
    }
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    
    /* We also need to recount the members */
    function bpfr_hide_get_total_filter($count){
    
    	// Counting the number of moderated users
    	$pending_users = bp_registration_get_pending_users();
    	$nb_pending_users = 0;
    	foreach( $pending_users as $pending_user ) {
    		$nb_pending_users += 1;
    	}
        // minus the two admins
        return $count-2-$nb_pending_users;
    }
    add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');
    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Awesome to hear that you got something working.

    Borrowing the bp_ajax_querystring callback for the issue linked above so that I can explore using it for the core plugin’s use.

    Thanks

    Hi Michael,

    I’m sorry, but I just discovered a new issue with this modification :

    If a user is validated by an admin but he never comes back to log in his profile after being validated, he won’t appear in the members list.

    Do you think you can help me with that ?

    Thank you.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I haven’t looked at the above mods since posted, due to other work priorities, so I’m not quite sure what would be causing it at the moment.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Should be fine as long as those approved members aren’t still getting returned in the pending users. Possible that there’s a transient that isn’t getting cleared out in your case.

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Members still listed in members lists before approve’ is closed to new replies.