Skip to content

Instantly share code, notes, and snippets.

@meetawahab
Last active January 1, 2020 06:54
Show Gist options
  • Save meetawahab/84d09684a43b7fc7096667f6d5e4305c to your computer and use it in GitHub Desktop.
Save meetawahab/84d09684a43b7fc7096667f6d5e4305c to your computer and use it in GitHub Desktop.
Redirect user to the referrer page after login to the WordPress site.
<?php
add_filter( 'login_redirect', function ( $redirect_to, $requested_redirect_to, $user ) {
if ( ! $requested_redirect_to ) {
$redirect_to = wp_get_referer();
}
return $redirect_to;
}, 10, 3 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment