Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
  • in reply to: Membership Level Permissions Do Not Work #182186
     bluelaserdesign
    Participant

    So there’s zero integration between all the crappy plugins you have packaged with the theme?

    This is so stupid and completely illogical. Why would anyone want site administrators in the members directory? Makes no sense.

    For others that have bought the theme and ran into the problem of this senseless decision, here is a script that will show only active members.

    COPY CODE
    function buddydev_exclude_users( $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 );
        }
    	
    	global $wpdb;
    
    	$active_users_arr = array();
    
    	$users = $wpdb->get_results( 
    		"
    		SELECT user_id, status 
    		FROM $wpdb->pmpro_memberships_users
    		WHERE status = 'active'
    		"
    	);
    
    	foreach ( $users as $user ) {
    	
    		array_push($active_users_arr,$user->user_id);
    		
    	}
        
        $user_ids = $active_users_arr; //user ids
        
        $excluded = array_merge( $excluded, $user_ids );
        
        $args['include'] = $excluded;
        
        return $args;
    }
    
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
Viewing 1 post (of 1 total)

Log in with your credentials

Forgot your details?