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.
3 Answers
write this code in front page to check user is login or not:
if ( is_user_logged_in() ) { ... }
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';
-
-
by using this you can find the user id get_current_user_id( ); Commented Jun 23, 2015 at 7:08
-
echo get_current_user_id(); give me 0 if user login or logout. Commented Jun 23, 2015 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; } Commented Jun 23, 2015 at 7:16
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
}