diff --git a/includes/reader-activation/class-reader-activation.php b/includes/reader-activation/class-reader-activation.php index e2c622dc27..c14f803c0c 100644 --- a/includes/reader-activation/class-reader-activation.php +++ b/includes/reader-activation/class-reader-activation.php @@ -462,21 +462,24 @@ public static function get_registration_newsletter_lists() { /** * Get the newsletter lists that should be rendered after checkout. * - * @param string $email Email address. + * @param string $email_address Email address. Optional. * * @return array */ - public static function get_post_checkout_newsletter_lists( $email ) { + public static function get_post_checkout_newsletter_lists( $email_address = '' ) { $available_lists = self::get_available_newsletter_lists(); $registration_lists = []; + $current_lists = []; if ( empty( $available_lists ) || ! method_exists( '\Newspack_Newsletters_Subscription', 'get_contact_lists' ) ) { return []; } - $current_lists = \Newspack_Newsletters_Subscription::get_contact_lists( $email ); - if ( \is_wp_error( $current_lists ) || ! is_array( $current_lists ) ) { - return []; + if ( $email ) { + $current_lists = \Newspack_Newsletters_Subscription::get_contact_lists( $email ); + if ( \is_wp_error( $current_lists ) || ! is_array( $current_lists ) ) { + return []; + } } foreach ( $available_lists as $list_id => $list ) { @@ -1401,11 +1404,7 @@ public static function render_newsletters_signup_modal() { return; } - $email_address = self::get_logged_in_reader_email_address(); - if ( ! $email_address ) { - return; - } - + $email_address = self::get_logged_in_reader_email_address(); $newsletters_lists = self::get_post_checkout_newsletter_lists( $email_address ); if ( empty( $newsletters_lists ) ) { return;