From 29f2480b2e15baa1506778256a3a384ea0bc5fe4 Mon Sep 17 00:00:00 2001 From: Eoin Gallagher <eoin@automattic.com> Date: Thu, 20 Mar 2025 19:31:07 +0000 Subject: [PATCH 1/4] Subscribe: fix default email --- .../jetpack/extensions/blocks/subscriptions/subscriptions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index f5255a38d5278..fce816d6ef70c 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -695,6 +695,8 @@ function render_block( $attributes ) { 'preselected_newsletter_categories' => get_attribute( $attributes, 'preselectNewsletterCategories', false ), ); + error_log( print_r( compact( 'data' ), true ) ); + if ( ! jetpack_is_frontend() ) { return render_for_email( $data, $styles ); } From 30ad7444c5b08d77ad0f3887746c37fc6a1d7682 Mon Sep 17 00:00:00 2001 From: Eoin Gallagher <eoin@automattic.com> Date: Thu, 20 Mar 2025 19:32:11 +0000 Subject: [PATCH 2/4] changelog --- .../jetpack/changelog/update-subscriber-button-default-email | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/update-subscriber-button-default-email diff --git a/projects/plugins/jetpack/changelog/update-subscriber-button-default-email b/projects/plugins/jetpack/changelog/update-subscriber-button-default-email new file mode 100644 index 0000000000000..825b6f82acb6d --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-subscriber-button-default-email @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Autofill logged in email' From 05965dd09a38772eababf1d94ec0bf2cb5ee6241 Mon Sep 17 00:00:00 2001 From: Eoin Gallagher <eoin@automattic.com> Date: Fri, 21 Mar 2025 15:55:26 +0000 Subject: [PATCH 3/4] add more debug - remove check on is_wpcom --- .../extensions/blocks/subscriptions/subscriptions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index fce816d6ef70c..36e20775b5b24 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -642,14 +642,17 @@ function render_block( $attributes ) { } $subscribe_email = Jetpack_Memberships::get_current_user_email(); + error_log( print_r( compact( 'subscribe_email' ), true ) ); /** This filter is documented in \Automattic\Jetpack\Forms\ContactForm\Contact_Form */ - if ( is_wpcom() || false !== apply_filters( 'jetpack_auto_fill_logged_in_user', false ) ) { + if ( false !== apply_filters( 'jetpack_auto_fill_logged_in_user', false ) ) { + error_log( 'jetpack_auto_fill_logged_in_user' ); $current_user = wp_get_current_user(); if ( ! empty( $current_user->user_email ) ) { $subscribe_email = $current_user->user_email; } } + error_log( print_r( compact( 'subscribe_email' ), true ) ); // The block is using the Jetpack_Subscriptions_Widget backend, hence the need to increase the instance count. ++Jetpack_Subscriptions_Widget::$instance_count; From 8784a7c436c29e4b0ff7d47ae709af1d4152839b Mon Sep 17 00:00:00 2001 From: Eoin Gallagher <eoin@automattic.com> Date: Fri, 21 Mar 2025 16:26:30 +0000 Subject: [PATCH 4/4] Remove check on filter --- .../extensions/blocks/subscriptions/subscriptions.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 36e20775b5b24..71be1d290b36d 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -641,18 +641,16 @@ function render_block( $attributes ) { return ''; } + // Prefill the email field with the current user's email if they are logged in via Memberships premium content token $subscribe_email = Jetpack_Memberships::get_current_user_email(); - error_log( print_r( compact( 'subscribe_email' ), true ) ); - /** This filter is documented in \Automattic\Jetpack\Forms\ContactForm\Contact_Form */ - if ( false !== apply_filters( 'jetpack_auto_fill_logged_in_user', false ) ) { - error_log( 'jetpack_auto_fill_logged_in_user' ); + // If no email, then prefill the email field with the current user's email if they are logged in + if ( empty( $subscribe_email ) ) { $current_user = wp_get_current_user(); if ( ! empty( $current_user->user_email ) ) { $subscribe_email = $current_user->user_email; } } - error_log( print_r( compact( 'subscribe_email' ), true ) ); // The block is using the Jetpack_Subscriptions_Widget backend, hence the need to increase the instance count. ++Jetpack_Subscriptions_Widget::$instance_count; @@ -698,8 +696,6 @@ function render_block( $attributes ) { 'preselected_newsletter_categories' => get_attribute( $attributes, 'preselectNewsletterCategories', false ), ); - error_log( print_r( compact( 'data' ), true ) ); - if ( ! jetpack_is_frontend() ) { return render_for_email( $data, $styles ); }