Jump to content

Recommended Posts

Posted

Hey,

 

In the top right hand corner of my site, http://borealtrek.com, there is a spot for users to login or register. When the user does this those links still appear. This is very redundant and kind of confusing for them. Is there any way to have it so that when they login it shows them their username which is linked to their information ect.

 

Thanks for the help!

 

This is what it looks like now.

 

This is what I want it to look like.

Posted

In your template file, put this (where appropriate):

 

<?php
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
   ?>
Login | Register
   <?php
} else {
   ?>
"<?php echo $current_user->user_login; ?>"
   <?php
}
?>

  • Like 1
Posted

Thank you man you did me a great favor! It all works well except for one thing. When the username shows up on the site it is not a link to the users info and ect. Any idea on how to do that? :D

Posted (edited)

When logged in, a user bar appears at the top of the page. You could just make this link disappear when a user is logged in.

Edited by maths222
Posted

Never mind that. I got it to work. lol I assumed html was much different from php. I did not know the two worked together.

 

$current_user = wp_get_current_user();

if ( 0 == $current_user->ID ) {

?>

<a href="http://borealtrek.com/wp-login.php">Login</a><a> | </a> <a href="http://borealtrek.com/wp-login.php?action=register">Register</a>

<?php

} else {

?>

<?php echo $current_user->user_login;?><a> | </a> <a href="http://borealtrek.com/wp-admin/profile.php">Settings</a>

<?php

}

?>

</li>

</ul>

<?php }

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...