I'm using the code below
<?php global $current_user; wp_get_current_user(); ?>
<?php if ( is_user_logged_in() ) {
echo 'سلام ' . $current_user->user_firstname . "\n"; echo '' . $current_user->user_lastname . "\n"; echo '/'; }
else { wp_loginout(); } ?>
to show the first name and last name of user on top bar when they are logged in and I want to show the login/register when they're not logged in. it is working fine when they are logged in but it doesn't show the login/register when they are not logged in. is there sth wrong with my code? should i change anything? I will appreciate any kind of help. thx.
Glad to help!
Your code is right. As i've just checked, the only problem it can be, is in the wp_loginout();
function.
I don't really know wp_loginout();
's real useage clearly, so i just guess it may output the login/register link you need.
I suggest you to replace wp_loginout();
with my code below, and try again to see, if it works well.('login.php' is only an example)
echo "<a href='login.php'>login/register</a>";
Hope it'll solve your problem,
Wish you a good day~