Categories

Determine if the current user is already logged in

Using is_user_logged_in() you can detect the status of the current user. In addition to this you can also call wp_get_current_user() which will set a global object the the current user information.

<?php require_once('wp-blog-header.php');?>
<?php define('WP_USE_THEME', false); wp_head(); ?>
<?php if (is_user_logged_in()): wp_get_current_user(); ?>
	<p>Welcome, <?=$current_user->user_login ?></p>
<?php else: ?>
	<p>Welcome, visitor</p>
<?php endif;?>

Learn more

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 12 + 14 ?
Please leave these two fields as-is: