Let’s say you own a multi-author wordpress blog, or a membership wordpress blog and you place a link to Login page on your blog’s theme. Now you wish to redirect every user to the same page he/she was before clicking on the Login Link on your theme instead of been redirected to the WordPress Dashboard.
For instance, a user was on your contact us page and decides to login by clicking on your login link at your sidebar, but you wish the user to be redirected back to the contact us page after login is successful instead of the wordpress dashboard backend, then here is a guide for you.
One thing I love about WordPress is because it’s got lots of function, we will be making use of the wp_login_url() wordpress function for this.
How to Automatically redirect to current page after login
Instead of placing the link directly to your login page from theme as
<a href=”http://yoursite.com/wp-login.php”>Click Here to Login</a>
Simply use the link below as
<a href=”<?php echo wp_login_url(get_permalink()); ?>” title=”Login”>Click Here to Login</a>
That’s it. A helpful wordpress tip