I try to everyone come to a post is not login, go to wp-login and after login back to the link requested. cheers!
this is the codes I tried:
<?php
$redirect = "http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
if (!is_user_logged_in()) {
wp_redirect( wp_login_url( $redirect ) );
exit();
}
?>
and try too:
<?php
if (!is_user_logged_in() ) {
wp_redirect( '/wp-login.php' . '?redirect_to=' . $_SERVER["REQUEST_URI"] );
exit;
}
?>
the URL when landing on wp-login is correct with all link (path) requested, but after click in Login button the user don't come back to the URL and go to the website main page for subscribers.