Adding Previous Page Redirection Support to Custom Login Forms
If you are using a WordPress custom login form or a login form from a plugin we currently do not integrate with, below is a code snippet to make our user redirection after log in previous/referrer page feature work with it.
add_action('wp_head', function() {
if(is_page(1817) && class_exists('\LoginWP\Libsodium\Redirections\Init')) {
\LoginWP\Libsodium\Redirections\Init::get_instance()->save_previous_page();
}
});
Don’t forget to replace 1817 with the ID of your login page.