Skip to content

Commit

Permalink
fix: redirect reader to login when logged out
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Nov 5, 2024
1 parent 53e9d98 commit 1bd87d5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion includes/plugins/class-woocommerce-subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ public static function is_active() {
* Redirect to subscriptions pending renewals my account page.
*/
public static function maybe_redirect_to_checkout_payment_page() {
if ( ! is_user_logged_in() || ! self::is_active() || ! isset( $_GET['np_renewal'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
if ( ! self::is_active() || ! isset( $_GET['np_renewal'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
return;
}

if ( ! is_user_logged_in() ) {
if ( ! is_account_page() ) {
wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) );
exit;
}
return;
}

$user_id = get_current_user_id();
if ( ! wcs_user_has_subscription( $user_id ) ) {
return;
Expand Down

0 comments on commit 1bd87d5

Please sign in to comment.