Skip to content

Commit

Permalink
fix: add redirect for logged out readers
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Nov 27, 2024
1 parent fa7cdc2 commit a01a0b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions includes/plugins/woocommerce-subscriptions/class-renewal.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static function maybe_redirect_renewal_endpoint( $query ) { // phpcs:igno
}
}
}
} else {
$redirect_url .= '?redirect=' . wc_get_account_endpoint_url( self::RENEWAL_ENDPOINT );
}
wp_safe_redirect( $redirect_url );
exit();
Expand Down
13 changes: 7 additions & 6 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,12 +1142,13 @@ public static function render_auth_form( $is_inline = false ) {
$terms_text = self::get_setting( 'terms_text' );
$terms_url = self::get_setting( 'terms_url' );
$referer = \wp_parse_url( \wp_get_referer() );
$redirect = '';

if ( Renewal::is_subscriptions_page() ) {
$redirect = Renewal::get_subscriptions_url();
} elseif ( function_exists( '\wc_get_page_id' ) && \get_the_ID() === \wc_get_page_id( 'myaccount' ) ) {
$redirect = \wc_get_account_endpoint_url( 'dashboard' );
$redirect = filter_input( INPUT_GET, 'redirect', FILTER_SANITIZE_URL );
if ( empty( $redirect ) ) {
if ( Renewal::is_subscriptions_page() ) {
$redirect = Renewal::get_subscriptions_url();
} elseif ( function_exists( '\wc_get_page_id' ) && \get_the_ID() === \wc_get_page_id( 'myaccount' ) ) {
$redirect = \wc_get_account_endpoint_url( 'dashboard' );
}
}

global $wp;
Expand Down

0 comments on commit a01a0b5

Please sign in to comment.