Is there any code to write username outside the loop? If the user is logged in of course :)
For example if the user is registered with username "myname", when he logs in automaticaly write "hello myname". How can I do it?
Is there any code to write username outside the loop? If the user is logged in of course :)
For example if the user is registered with username "myname", when he logs in automaticaly write "hello myname". How can I do it?
Something like this should work - THIS IS UNTESTED! - There may be simpler ways, natch.
<?php if (is_user_logged_in()){
global $current_user;
get_currentuserinfo();
echo('Hello, ' . $current_user->user_login . "!\n");
}
else {
echo "Welcome, visitor!";
};
?>Well it works fine! Thank you for help very much!
And how to make the username linked to it's profile page? (not on dashboard main page)
Hmm. I think it'd be this.
echo('Hello, <a href="http://www.domain.com/author/' . $current_user->user_login . '">' . $current_user->user_login . !</a>\n');
My only worry is I may be having a stupid moment between " and ' in the echo statement :/
Something is wrong in this code :(
Parse error: syntax error, unexpected '<'
Well I corrected the code, it would be
echo('Hello, <a href="wp-admin/profile.php">' . $current_user->user_login . !'</a>\n');
}
Ipstenu
Thank you again for help :)
OH! You meant a link to edit the profile! Heh, I was thinking a link to view it. Glad it worked for you! Happy happy.
Is it possible that only view the profile without the ability to edit it? I have never heard anything about it. What does the page look like?
That's the URL I gave you before.
http://www.domain.com/author/<name>
You may want to change <a href="wp-admin/profile.php"> to <a href="/wp-admin/profile.php"> by the way, or /blog/, depending on how you set up your blog, so that it will work from every page.
And I see where I got the code wrong and why you had the unexpected <
echo('Hello, <a href="/wp-admin/profile.php">' . $current_user->user_login . '!</a>\n')
Put the ` on the left of the !, basically. I left it off my first example!
This topic has been closed to new replies.