I want users "subscribers" to be redirected to the page they last viewed. At the moment, users are redirected to their "myaccount" profile page (my-account.php). I am trying to figure out how to adjust what I have already, or where to insert some script from another post on here.
I am fairly sure there is no database work to do here, its a only a change to the script, right?
Can anyone please check this wp-login.php script, and let me know what to change? I also have 2 functions.php files within the public_html structure.
Thank you in advance...
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
/**
* Filters the login redirect URL.
*
* @since 3.0.0
*
* @param string $redirect_to The redirect destination URL.
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
* @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
*/
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
if ( ! is_wp_error( $user ) && ! $reauth ) {
if ( $interim_login ) {
$message = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>';
$interim_login = 'success';
login_header( '', $message );
?>
</div>
<?php
/** This action is documented in wp-login.php */
do_action( 'login_footer' );
if ( $customize_login ) {
?>
<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
<?php
}
?>
</body></html>
<?php
exit;
}