Who is Online
[resolved] Author online status (2 posts)

  1. Dominor Novus
    Posted 3 years ago #

    For author.php I'd like to be able to output whether or not the author is online.

    Can I achieve that with this plugin?


  2. Dominor Novus
    Posted 3 years ago #

    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));
    // 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>";
    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Who is Online
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic