WordPress: Display Online Users' Avatars

Posted by Wade D Ouellet on Stack Overflow See other posts from Stack Overflow or by Wade D Ouellet
Published on 2010-05-11T02:36:21Z Indexed on 2010/05/11 2:44 UTC
Read the original article Hit count: 305

Filed under:
|
|
|
|

Hi,

I'm using version 2.7.0 of this WordPress plugin to display which users are currently online (the latest version doesn't work): http://wordpress.org/extend/plugins/wp-useronline/

It's working great but I would love to be able to alter it quickly to display the users' avatars instead of their names. Hoping someone with pretty good knowledge of WordPress queries and functions can help.

The part below seems to be the part that handles all this. If this isn't enough, here is the link to download the version I am using with the full php files: http://downloads.wordpress.org/plugin/wp-useronline.2.70.zip

// If No Bot Is Found, Then We Check Members And Guests
        if ( !$bot_found ) {
            if ( $current_user->ID ) {
                // Check For Member
                $user_id = $current_user->ID;
                $user_name = $current_user->display_name;
                $user_type = 'member';
                $where = $wpdb->prepare("WHERE user_id = %d", $user_id);
            } elseif ( !empty($_COOKIE['comment_author_'.COOKIEHASH]) ) {
                // Check For Comment Author (Guest)
                $user_id = 0;
                $user_name = trim(strip_tags($_COOKIE['comment_author_'.COOKIEHASH]));
                $user_type = 'guest';
            } else {
                // Check For Guest
                $user_id = 0;
                $user_name = __('Guest', 'wp-useronline');
                $user_type = 'guest';
            }
        }

        // Check For Page Title
        if ( is_admin() && function_exists('get_admin_page_title') ) {
            $page_title = ' » ' . __('Admin', 'wp-useronline') . ' » ' . get_admin_page_title();
        } else {
            $page_title = wp_title('»', false);
            if ( empty($page_title) )
                $page_title = ' » ' . strip_tags($_SERVER['REQUEST_URI']);
            elseif ( is_singular() )
                $page_title = ' » ' . __('Archive', 'wp-useronline') . ' ' . $page_title;
        }
        $page_title = get_bloginfo('name') . $page_title;

        // Delete Users
        $delete_users = $wpdb->query($wpdb->prepare("
            DELETE FROM $wpdb->useronline 
            $where OR timestamp < CURRENT_TIMESTAMP - %d
        ", self::$options->timeout));

        // Insert Users
        $data = compact('user_type', 'user_id', 'user_name', 'user_ip', 'user_agent', 'page_title', 'page_url', 'referral');
        $data = stripslashes_deep($data);
        $insert_user = $wpdb->insert($wpdb->useronline, $data);

        // Count Users Online
        self::$useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about users