File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -601,16 +601,19 @@ private function populate_orders() {
601601 $ this ->orders = null ;
602602 if ( isset ( $ _SERVER ['REQUEST_URI ' ] ) ) {
603603 $ redirect_url = esc_url_raw ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) );
604- $ login_url = wp_login_url ( $ redirect_url );
605- wp_safe_redirect ( $ login_url );
604+ } else {
605+ $ redirect_url = home_url ();
606+ }
607+ if ( isset ( $ _GET ['need_login_message ' ] ) && $ _GET ['need_login_message ' ] === 'true ' ) { // phpcs:ignore
608+ echo '<div class="notice notice-info"><p> ' . __ ( 'You need to be logged in to access this page. Please log in first. ' ) . '</p></div> ' ; // phpcs:ignore
609+ // Display a confirmation button to redirect the user to the login page.
610+ echo '<a href=" ' . wp_login_url ( $ redirect_url ) . '" class="button">Proceed to Login</a> ' ; // phpcs:ignore
606611 exit ;
607612 } else {
608- wp_safe_redirect ( wp_login_url ( ) );
613+ wp_safe_redirect ( add_query_arg ( ' need_login_message ' , ' true ' , $ redirect_url ) );
609614 exit ;
610615 }
611- return false ;
612616 }
613-
614617 // Save the order to get it without an additional database call.
615618 $ this ->orders [ $ wdn_order_id ] = $ order ;
616619 }
You can’t perform that action at this time.
0 commit comments