I’m trying to have my header say the user is logged in and give them the option to log in if they’re not. I’m really close. I’ve added this line of code beneath my header discription :
<?php if ( $user_ID ) : ?>
Logged in as
<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>
<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">
<?php else : ?>
<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">
<?php endif; ?>
I have weird spacing on this post for demonstration purposes.
The code is a modification of the code for commenting when logging in is required. The thing works beautifully except that the $user_identity doesn’t echo/report/display or whatever. If logged in it says “Logged in as . Logout »” instead of “Logged in as <username>. Logout »”
I’m far from learned in php, so this could be a misplaced comma on my part or it could be impossible. Any insight and help is greatly appriciated.