Skip to content

Conversation

vianasw
Copy link
Contributor

@vianasw vianasw commented Oct 7, 2025

Introduces a new notifications system that allows site administrators to specify which users should receive notifications when form responses are submitted.

Proposed changes:

  • Add NotificationsSettings component to manage notification recipients
  • Implement form-notifications feature flag (default: disabled)
  • Store notification recipients as a form-level attribute
  • Add notificationRecipients attribute to Contact_Form defaults
  • Update Feedback class to retrieve recipients from form attributes
  • Add PHP filter jetpack_forms_enable_notifications to control the feature

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

Prerequisites:

To enable this feature you have to add this filter:
add_filter( 'jetpack_forms_enable_notifications', '__return_true' );

  • With the filter enabled, create a form and check that the sidebar has a section titled Form notifications.
Screenshot 2025-10-08 at 10 44 23
  • Check that when enabled, the author of the post is set by default as the recipient of the notification.
Screenshot 2025-10-08 at 10 44 34
  • Add another user (like an editor) to the recipients list, save the draft, reload, and check that the recipients list has been persisted.
  • Try to add to the recipients list a user who shouldn't have access to the post (like a subscriber), and confirm that it's not possible to do so.
  • Disable the form response notifications and check that the recipients list collapses.
  • Lastly, remove the feature flag filter and check that the Form notifications section is no longer present in the sidebar panel

Copy link
Contributor

github-actions bot commented Oct 7, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/form-notifications-panel branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/form-notifications-panel

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Oct 7, 2025
Copy link
Contributor

github-actions bot commented Oct 7, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Oct 7, 2025
Copy link

jp-launch-control bot commented Oct 7, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-feedback.php 548/566 (96.82%) -0.27% 2 ❤️‍🩹
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 395/595 (66.39%) -0.11% 1 ❤️‍🩹
projects/packages/forms/src/contact-form/class-contact-form.php 601/1121 (53.61%) 0.04% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/forms/src/blocks/contact-form/components/notifications-settings.js 30/35 (85.71%) 💚

Full summary · PHP report · JS report

'ip' => $this->ip_address,
'subject' => $this->subject,
'ip' => $this->ip_address,
'notification_recipients' => $this->notification_recipients,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me :)

Make it less verbose since we're already in the JetpackForms context.
Renamed to NotificationsSettings.
We don't need to store notification_recipients in a field like we're
doing with subject—which is done that way for legacy reasons. It should
come via the JWT token which is searlized and unsearlized on form
submission then available via the form attributes
@vianasw vianasw added the [Status] Needs Review This PR is ready for review. label Oct 8, 2025
@vianasw vianasw added [Type] Feature Development of a new feature and removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Oct 8, 2025
@vianasw vianasw marked this pull request as ready for review October 8, 2025 09:09
Added server side validation of the notification recipients to make sure
they should receive the notifications—protection against frontend
tampering. It also covers the case where the user role might have
changed. I've added unit tests covering these cases
@vianasw vianasw requested a review from lezama October 8, 2025 17:24
* @param array $recipients The notification recipients.
* @return void
*/
public function set_notification_recipients( $recipients ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell we don't use this anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [Type] Feature Development of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants