Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter charliewebnancy

    (@charliewebnancy)

    Thanks ! It was just to be sure… ??

    Thread Starter charliewebnancy

    (@charliewebnancy)

    Fix : Upload a mute video.

    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.

    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');

    I really think that my function could work for what I need to do if I could get moderated users IDs in my functions.php…

    Is there a function or something I could call to get the IDs ?

    I tried to paste that code :

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    	# Test for BP Component object
    	if ( ! empty( $_POST['object'] ) ) {
    		$object = sanitize_title( $_POST['object'] );
    
    		if ( bp_is_active( $object ) ) {
    			add_filter( 'wp_ajax_' . $object . '_filter', 'bp_registration_hide_ui', 1 );
    		}
    
    	} else {
    		# Some AJAX requests still come through the 'init' action
    		bp_registration_hide_ui();
    	}
    }
    
    function bp_registration_options_disable_ajax() {
    	?>
    <script>
    	jQuery(document).ready(function($) {
    		$('.item-list-tabs, .item-list-tabs li, .item-list-tabs a').addClass('no-ajax');
    	});
    </script>
    <?php
    }

    Unfortunately, it doesn’t hide the moderated users after clicking the “all members” button, but it also shows the admins who were hidden by a function in functions.php… Maybe my function is causing the bug :

    //on masque le superadmin sur l'annuaire des membres
    function bpdev_exclude_users($qs=false,$object=false){
    
        $excluded_user='1,4'; //séparer par des virgules les ID des membres que vous souhaitez cacher
    
        if($object != 'members') //on cache pour les membres
        return $qs;
    
        $args=wp_parse_args($qs);
    
        //on ne cache PAS le profil aux amis
    
        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);
    
    // il faut aussi recompter les Membres
    function bpfr_hide_get_total_filter($count){
        return $count-2;
    }
    add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');

    Yes, sorry. In the buddypress members list (originally the page named “members”) you can’t see the moderated users first, but if you click on “all members” (or something like that, mine is in french), the moderated users appear. It means that you can also visit the moderated members profiles, even if you are not logged in. I would like to set them completely invisible, except from themselves.

    Capture 1

    Capture 2

    I have downloaded and installed the Github version, but nothing has changed.
    I only need two simple instructions :

    • if ( $moderate ) : hide member
    • And maybe redirect on home page if someone try to access the moderate member profile (except the member himself)

    Could you give me some useful php instructions to paste in core.php ?
    Or at least the right function to call if you know it ?

    Thank you again.

    Hi,

    I have the same problem. If you had fix it in the past, could you please tell me how ?

    Thank you very much !

Viewing 9 replies - 1 through 9 (of 9 total)