Skip to content

Commit 8682a38

Browse files
authored
Merge pull request #414 from TycheSoftwares/change-412
Fix #412
2 parents 5377c0a + d40399b commit 8682a38

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

includes/class-wcdn-print.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)