1

I want to check if special user id is logged in WordPress. i know we have a function name is_user_logged_in() but we can't change the id of user logged in, in this function.

I need a function like this:

is_special_user_logged_in();

and check it like this:

if ( is_special_user_logged_in() ){ echo 'special user is online'; }

i can get the user id in one of bbpress file (loop-single-reply.php) by this code. get_post_field( 'post_author', bbp_get_reply_id() ); .Now i want to check if this user id logged in wordpress show a text like "this user is online". Note that i want to check it in another user logged in WordPress. it's mean if "USER A" logged in wordpress show a text to "USER B" that "USER A" is now logged in wordpress.

finally want to inform USER A about login status of USER B

2

I am not sure exactly what you are asking for, but, if you want to target a specific user ID, just do something like:

// set special user id
$special_user_id = 5;

$current_user_id = get_current_user_id();

if ( $special_user_id == $current_user_id ){
    echo 'special user is online';
}

You get the idea.

  • 1
    you posted 7 seconds before me, I will remove mine ;-) – birgire Apr 11 '15 at 13:47
  • @birgire No, keep yours. You're approach is slightly better to be honest. – Christine Cooper Apr 11 '15 at 13:48
  • Excuse me but it's not my question answer. i explain it again with more details. i can get the user id in one of bbpress file (loop-single-reply.php) by this code. get_post_field( 'post_author', bbp_get_reply_id() ); .Now i want to check if this user id logged in wordpress show a text like "this user is online". Note that i want to check it in another user logged in WordPress. it's mean if "USER A" logged in wordpress show a text to "USER B" that "USER A" is now logged in wordpress. I hope you've noticed. – saeed shabani Apr 11 '15 at 14:15
  • Do you mean: If $user_a login and $user_b is already logged in, then inform $user_a about it. Is that correct? – Christine Cooper Apr 11 '15 at 14:26
  • 1
    This has already been resolved in the following answer: stackoverflow.com/questions/8559759/… – Christine Cooper Apr 12 '15 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.