Lately I’ve been putting a login link in the footer of my site, but it’s also nice for that to be a logout link when you’re already logged in as well as inserting a link to the site admin section. This line of code does exactly that:
<?php if ( is_user_logged_in() ) { echo "<a href='" . get_option('siteurl') . "/wp-admin/'>Site Admin</a> |"; } ?> <?php wp_loginout(); ?>
Just what I have been searching for. Is it possible to show a "Welcome Username!" to this line as well?
To get the current user’s username, try this bit of code.
$curr = getcurrentuserinfo();
$currUser = curr->displayname;
Sorry to double comment, is there also a way to control the page that comes up after a user logs in? I want them to stay on the current page instead of being pushed to their admin section. There's really not much info on how to do this on the wordpress site, that I was able ti find anyways.