How can I check the access level of displayed user?

How can I check the access level of displayed user?

Is there a simple function?

I’ve read about using this: (“1” being the level I’m focusing on)

$member = new M_Membership( $user_id );

if(!empty($member)) {
return $member->on_level( 1, true );
} else {
return false;
}

I’ve tried using this but I’m not sure I am understanding it right.

I found this function also in the membership functions.php

function current_user_on_level( $level_id ) {

$user = wp_get_current_user();
$member = new M_Membership( $user->ID );

if(!empty($member)) {
return $member->on_level( $level_id, true );
} else {
return false;
}

}

It would be nice if there was a function similar to wp_get_current_user(); but for displayed user.

Any suggestions?

I’m teaching myself all of this so forgive me if I’m way off.

update. So i think I got closer with this

function displayed_user_on_level( $level_id ) {
global $bp;
$displayedUser = $bp->displayed_user->ID;
$member = new M_Membership( $displayedUser );

if(!empty($member)) {
return $member->on_level( $level_id, true );
} else {
return false;
}
}

but it always returns false. Can I get some help please? Thanks in advance