Automattic / Automattic/jetpack
Subscriptions: post-subscribe redirection behavior no longer customizable
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
Prior to Jetpack 12.2, specifically #28170, when submitting the Subscription block, the submission went through `Jetpack_Subscriptions`'s `widget_submit` method:
https://github.com/Automattic/jetpack/blob/4fb690625a04c22b689a610a379081858e1780d9/projects/plugins/jetpack/modules/subscriptions.php#L102-L105
This process handles the submission and ends with a redirect that can be customized via a filter:
https://github.com/Automattic/jetpack/blob/4fb690625a04c22b689a610a379081858e1780d9/projects/plugins/jetpack/modules/subscriptions.php#L768-L779
In practice, that means you could do something like this to redirect folks to a "Thank you" page upon submission, for example:
```php
/**
* Redirect all successful subscription submissions to a 'thank-you' page
*/
function jeherve_custom_sub_redirect_page( $result ) {
if ( 'success' === $result ) {
$thanks_page = 'thank-you';
wp_safe_redirect( $thanks_page );
exit;
}
}
add_action( 'jetpack_subscriptions_form_submission', 'jeherve_custom_sub_redirect_page' );
```
This no longer works now, since the submission process reloads the same page instead:
https://github.com/Automattic/jetpack/blob/94ddae8284758db97529fad30752b9e11a556bb1/projects/plugins/jetpack/extensions/blocks/subscriptions/view.js#L52-L55
It would be nice if the existing filter could continue to work like before, taking over the submission process when it is set.
Contributor guide
Research direction
Compare the historical Jetpack_Subscriptions::widget_submit flow and its redirect filter in projects/plugins/jetpack/modules/subscriptions.php with the current submission handling in projects/plugins/jetpack/extensions/blocks/subscriptions/view.js. Start by tracing where the block reloads the page; done means the existing jetpack_subscriptions_form_submission action can again take over successful submissions and redirect to a custom destination.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100