lampromy
Member
Posted 6 months ago #
Code below will take you automatically to the wordpress login page and after successful login its will be back to the requested page. You just need to keep this code top of the page.
if(!function_exists(is_user_logged_in)){
die('Sorry, You do not have access of this page.');
}
if ( !is_user_logged_in() ) {
$returnPath = get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']);
echo "<script type='text/javascript'>";
echo "window.location.href='$returnPath'";
echo "</script>";
exit();
}
Where do you insert this code?
rexolio
Member
Posted 1 month ago #
bump!
Where do you insert the code?
I tried this on wp-login.php and it looped indefinitely to wp-login.php.
rexolio
Member
Posted 1 month ago #
brockangelo,
you may have figured out what to do already, but I found this post at which shows how to handle it very, very simply: http://davidchambersdesign.com/wordpress-login-redirect/
Works whether you use it as a link or form action.
Rex
I appreciate that link rexolio. I had set this project off to the side, but now it works like a charm!