Find out if a user is logged into wordpress from id

I am looking for a function to check if a user is logged into wordpress via their id.

i am aware of this function.

Read More
if ( is_user_logged_in() ) {
    echo 'Welcome, registered user!';
} else {
    echo 'Welcome, visitor!';
} 

but i was wondering if their is a function that does it via id so it would be like the following below.

if ( is_user_logged_in(1) ) {
    echo 'this user is logged in';
}

cant find one anywhere.

Related posts

Leave a Reply

1 comment

  1. you can go around it like:

    if ( is_user_logged_in() ) {
         $current_user = wp_get_current_user();
         if ( 1 == $current_user->ID ) {
          // do stuff.
         } else {
           // do stuff.
         }
     }