How to check membership level/subscription(using buddypress)

using the members loop in buddypress, I want to be able to exclude those who have not paid to renew their membership. Any simple way to do this?

  • aecnu

    Greetings bbattenfeld,

    Welcome to WPMU DEV!

    This is indeed not the intended use of this plugin and I foresee plenty of issues involving the plugin itself since it controls the entire site to include the renewal process.

    The end users are never going to make it to the Buddy Press loop if their membership has expired.

    Any simple way to do this?

    Not that I am aware of but I am not a coder.

    Therefore I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Barry

    There are a collection of functions in the plugins functions.php file that are based on checks for the current user, but that can be used as the basis for custom functions / checks.

    An example of one of the functions is:
    current_user_is_member()

    The code for which has the following in it:

    function current_user_is_member() {
    
    	$user = wp_get_current_user();
    	$member = new M_Membership( $user->ID );
    
    	if(!empty($member)) {
    		return $member->is_member();
    	} else {
    		return false;
    	}
    
    }

    The key parts are to create a member object for the user (passing the user_id), and then check the is_member method to see if they are a member or not.

    Hope that helps :slight_smile:

  • aecnu

    Greetings bbattenfeld,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

  • bbattenfeld

    Hey, sorry guys. Yes, it's resolved. I'll post the solution below. Sorry if the formatting gets a little messed up, but I haven't posted code on these forums before. Basically just stored the IDs of the members who were inactive in an array, and passed that array to be excluded from the bp_has_members() function.

    $InactiveMemberArray = array();
    while ( bp_members() ) : bp_the_member(); 
    
    $member = new M_Membership( bp_get_member_user_id() );
    if ($member->active_member()==false){
    array_push($InactiveMemberArray, bp_get_member_user_id());
    }
    endwhile;
    $InactiveMemberArray=implode(",",$InactiveMemberArray);
    
    bp_has_members( bp_ajax_querystring( 'members' ). "&search_terms=yes"."&exclude=".$InactiveMemberArray );

    The code I pasted

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.