Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: finding out user_level


Burt Adsit
Participant

@burtadsit

There’s this function in the bp admin bar:

// return a string indicating user’s role in that blog

function get_blog_role_for_user( $user, $blog ) {

// If the user is a site admin, just display admin.

if ( is_site_admin() )

return __( ‘Admin’, ‘buddypress’);

$roles = get_usermeta( $user, ‘wp_’ . $blog . ‘_capabilities’ );

if ( isset( $roles ) )

$role = __( ‘Subscriber’, ‘buddypress’ );

elseif ( isset( $roles ) )

$role = __( ‘Contributor’, ‘buddypress’ );

elseif ( isset( $roles ) )

$role = __( ‘Author’, ‘buddypress’ );

elseif ( isset( $roles ) )

$role = __( ‘Editor’, ‘buddypress’ );

elseif ( isset( $roles ) )

$role = __( ‘Admin’, ‘buddypress’ );

else

return false;

return $role;

}

It determines the user’s role. That what you need?

You might just be missing the current user in that function you created. Gotta remember the global vars.

global $current_user;

The info that bp tracks for a user is what bp needs to know about the user. The rest is provided by wpmu.

Skip to toolbar