Skip to:
Content
Pages
Categories
Search
Top
Bottom

finding out user_level

  • hi,

    On my site, http://www.plugin.com, i need to list users who are authors only in the sidebar widget on the home page. i created a new sidebar widget (Companies) for this but cant seem to get the user_level data back from the bp_core?

    i created the following routine in bp_cure

    function bp_core_get_userlevel( $user_id) {

    $user_info = get_userdata($user_id);

    //debugging

    echo(‘Username: ‘ . $user_info->user_login );

    echo(‘User level: ‘ . $user_info->user_level );

    echo(‘User ID: ‘ . $user_info->ID );

    return $$user_info->user_level;

    }

    its being called in bp-core-widgets.php like this

    <div class=”item-meta”><span class=”activity”><?php echo bp_core_get_userlevel( $user->user_id ) ?></span></div>

    But i cant get it to return the userl_level. With the debugging on, it returns user_login and ID but user_level is always empty/blank?

    I have tried every other possible way to do this but cant seem to get it to work.

    Any help would be greatly appreciated

    thanks

    karsten

Viewing 3 replies - 1 through 3 (of 3 total)
  • help mplease how hard can this be??? i would think that buddypress should be giving access to all core user data?


    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.

    hmm moving in the right direction, the thing is i am looping thorugh all the user id’s using the code in the ‘latest users’ widget in the bp_core in order to show user level on the home page

    so i dont know the blog id just the user id. what i want to do is create a 2nd widget that shows latest blog authors vs just showing latest generic users

    i looked at the bp_core and it seems to have routines for everything but showing the user_level… i will take a look at get_userrmeta and see if i can use this without knowing the blog but it doesnt seem like the way to go…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘finding out user_level’ is closed to new replies.
Skip to toolbar