From c685c15bd735f623743d1b10733fe87f163d0862 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Sun, 11 Sep 2022 20:21:53 -0400 Subject: [PATCH] Redirect to referrer on log out with optional filter --- functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 271811f..7b76f0b 100644 --- a/functions.php +++ b/functions.php @@ -488,9 +488,14 @@ function memberlite_login_redirect_to() { return apply_filters( 'memberlite_login_redirect_to', esc_url( $redirect_to ) ); } -/* Get the redirect_to URL to use for "Log Our" links. */ +/* Get the redirect_to URL to use for "Log Out" links. */ function memberlite_logout_redirect_to() { - return apply_filters( 'memberlite_logout_redirect_to', home_url() ); + if ( isset( $_SERVER['REQUEST_URI'] ) ) { + $redirect_to = home_url( esc_url( $_SERVER['REQUEST_URI'] ) ); + } else { + $redirect_to = home_url(); + } + return apply_filters( 'memberlite_logout_redirect_to', esc_url( $redirect_to ) ); } /* Adds a Log Out link in member menu */