show subscriptionlevel on memberslist

Hello!

So far I'm pretty happy with the Membership plugin!
I just would like to show the subscription-level of every member on the members-page (buddypress). Is there a shortcut method that I can use for that?
I also would like to filter the members by subscription level.

Any advise is appreciated!

  • Ash

    Please create a page with 'custom-member' slug. Then add the following code in your functions.php:

    add_filter('the_content', 'show_member_details');
    function show_member_details($content) {
    	global $post;
    	if($post->slug = 'custom-member')
    	{
    		$data = '<table cellspacing="5" cellpadding="5">';
    			foreach($users as $user){
    				$member = new M_Membership( $user->ID );
    				$data .= '<tr>';
    					$data .= '<td>';
    						$data .= $user->data->display_name;
    					$data .= '</td>';
    					$data .= '<td>';
    						$data .= get_user_sub($member->current_subscription());
    					$data .= '</td>';
    					$data .= '<td>';
    						$data .= get_user_level($member->get_level_ids());
    					$data .= '</td>';
    				$data .= '</tr>';
    			}
    		$data .= '</table>';
    		return $data;
    	}
    	return $content;
    }
    
    function get_user_sub($array) {
    	$temp = array();
    	foreach($array as $arr){
    		$subs = new M_Subscription($arr->sub_id);
    		array_push($temp, $subs->sub_name());
    	}
    	return implode($temp, ', ');
    }
    
    function get_user_level($array){
    	$temp = array();
    	foreach($array as $a){
    		$level = new M_Level($a->level_id);
    		array_push($temp, $level->level_title());
    	}
    	return implode($temp, ', ');
    }

    You can change the slug as your own, but make sure you use the correct slug in the code, in line 4.

    If you have custom member page for buddypress, I hope you will be able to integrate this code in that custom page :slight_smile:

    Please let me know if you find this is helpful, or if you have any further questions.

    Cheers
    Ash

  • martijn_baart7

    Hello Ash,

    Thank you for your reply! I tested it and it works perfectly. For now I will only use the functions get_user_level() and get_user_sub(). I integrated it in the custommemberspage by putting the following code inside the membersloop:

    $member = new M_Membership(bp_get_member_user_id());
     echo get_user_sub($member->current_subscription());
     echo get_user_level($member->get_level_ids());

    Hope this will help others aswell :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.