2

I am using "front-end-only-users" plugin for user registration and log in system. Now how i check that my front end user is log in or not through coding i use 'is_user_logged_in()' but it checking the admin panel user.

2

write this code in front page to check user is login or not:

 if ( is_user_logged_in() ) { ... } 
1

Hope this will helful to you

global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( user_can( $current_user, "subscriber" ) ) 
    echo 'User is a Subscriber';
else
    echo 'User is not a Subscriber';
  • how to check the user id. – Nasir khan Jun 23 '15 at 7:06
  • by using this you can find the user id get_current_user_id( ); – Anam Shah Jun 23 '15 at 7:08
  • echo get_current_user_id(); give me 0 if user login or logout. – Nasir khan Jun 23 '15 at 7:15
  • $user_id = get_current_user_id(); if ($user_id == 0) { echo 'You are currently not logged in.'; } else { echo 'You are logged in as user '.$user_id; } – Anam Shah Jun 23 '15 at 7:16
1

The CheckLoginCookie() function will help you to get the current login username

you can get the username by using bellow code

$UserCookie = CheckLoginCookie();
$username  = $UserCookie['Username'];
if($username){
  // User Login
}else{
   // User Not login
}

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.