WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Who is Online] Author online status

[Resolved] [Plugin: Who is Online] Author online status

Viewing 1 replies (of 1 total)
  • Dominor Novus
    Member

    @dominor-novus

    I’ve figured it out. Add the following to your page template:

    //Set the $curauth variable
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    endif;
    
    // Define the ID of whatever authors page is being viewed.
    $authortemplate_id = $curauth->ID;
    
    // Connect to database.
    global $wpdb;
    // Define table as variable.
    $who_is_online_table = $wpdb->prefix . 'who_is_online';
    // Query: Count the number of user_id's (plugin) that match the author id (author template page).
    $onlinestatus_check = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM ".$who_is_online_table." WHERE user_id = '".$authortemplate_id."';" ) );
    
    // If a match is found...
    if ($onlinestatus_check == "1"){
    echo "<p>User is <strong>online</strong> now!</p>";
    }
    else{
    echo "<p>User is currently <strong>offline</strong>.</p>";
    }

    Further reading: http://wordpress.stackexchange.com/questions/34429/how-to-check-if-a-user-not-current-user-is-logged-in

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] [Plugin: Who is Online] Author online status’ is closed to new replies.