How to display status of commentator in wordpress

everybody

i have my site in WordPress, in my site i have created one forum page for user discussion using WordPress default comment form.

Read More

in my comment form i also want to show status of commentator in order to check that whether it is online or offline by using simple text [Online/Offline]

right now i am using code given below

    <div class=skyblue></br>
    <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
                <font color=red size=5><?php printf( __( '<cite >%s</cite> ' ), get_comment_author_link() ); ?></font>

<div align=right><?php 
$user_id   = get_comment(get_comment_ID())->user_id;

if ($user_id)
{
    $user_info = get_userdata($user_id );
    {
 echo 'Online';
      } else {
      echo 'Offline';
     }
} ?></div>

    <div  align="left"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
                <?php
                    /* translators: 1: date, 2: time */
                    printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
                ?><br>
            </br></div></div>

above image show how commentator status looks like

can anybody help me in order to show status of commentator in wordpress

Related posts