Getting membership level for a particular user


I’m using Buddypress 1.2.8 with the Membership 2.0.4 plugin. I’m trying to filter and sort the Buddypress Members directory by membership level.

Does Membership have a built-in function to return any user’s level id?

I looked for something like “get_member_level()” but couldn’t find it. I was able to get the membership level for a particular user (not the logged-in user) by doing this in the while ( bp_members() :…:wink: loop in the templates:

$member_id = bp_get_member_user_id();

$is_premium = user_is_premium($member_id);

if (user_is_premium($member_id)){

….do stuff with user profile info in members directory…


I put the user_is_premium function in a plugin:

# adapted from function current_user_on_level( $level_id )

# in membership/membershipincludes/includes/functions.php

function user_is_premium($member_id){

$member = new M_Membership( $member_id );

if(!empty($member)) {

return $member->on_level( ‘3’, true );

} else {

return false;



It seems to work fine. I’m just wondering if there’s a simpler/cleaner way to do it using Membership functions.