I am a fan of most things WordPress, but one thing I am not a fan of is the way that everyone gets sent to the Dashboard whenever they log in. Not everyone who logs into your site will write posts or administer the site. And for an intranet, this is a drag.
What I’ve always wanted was a way to reload the current page after I have logged in. So if I’m on the “Search” page, I just want to go to the login page, then go back to the page I was on when I clicked the “Login” link. Finally – a solution!
Thanks to David Chambers – it is as easy as changing the url that the “login” link points to.
<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>">log in</a>
He calls it WordPress Login Redirect. I would imagine that this would be a handy plugin for a lot of people. On an intranet, you may want to provide a link to the dashboard if they are an admin, or a link to logout if they are not. I have been using a very simple conditional statement that determines what to put in place of the login link after you are logged in.
<?php
global $current_user;
get_currentuserinfo();
if (!(is_user_logged_in())) { ?>
<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>">Log in</a>
<?php } elseif
(
(($current_user->user_login) == "brock") ||
(($current_user->user_login) == "admin")
)
{
echo "<a href=\"";
echo get_option('siteurl');
echo "/wp-admin/\">Dashboard</a>";
} else { ?>
<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>
<?php
}
?>