WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Foreach with get_users_browsing_site?

[Resolved] Foreach with get_users_browsing_site?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Lester Chan

    @gamerz

    Try

    $users = UserOnline_Template::compact_list( 'site' , 'list' );

    Hmmmm…this is what I have:

    $users = UserOnline_Template::compact_list( 'site' , 'list' );
    
    foreach($users as $user) {
        echo $user;
    }

    It returns this error: Catchable fatal error: Object of class stdClass could not be converted to string.

    Plugin Author Lester Chan

    @gamerz

    the $user is an object not a string, you do a var_dump($user); instead of echo $user; and see what it returns first.

    Ah, duh 😉 Thanks!

    For anyone else wanting to extract this info, here is the beginnings of what I’m setting up in order to grab the user avatar and customize the list.

    if (function_exists('get_users_browsing_site')):
        $users = UserOnline_Template::compact_list( 'site' , 'list' );
            foreach ($users as $user) {
                echo get_wp_user_avatar( $user->user_id, 'thumbnail' );
                echo '<a href="'. get_author_posts_url( $user->user_id ) .'">';
                echo $user->user_name;
                echo '</a>';
            }
    endif;
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Foreach with get_users_browsing_site?’ is closed to new replies.