Skip to content

Conversation

@CGastrell
Copy link
Contributor

@CGastrell CGastrell commented Dec 8, 2025

Fixes https://linear.app/a8c/issue/FORMS-434/allow-collecting-webhooks-from-filter

Proposed changes:

  • Add jetpack_forms_extra_webhooks filter to allow programmatically adding webhooks via code before webhook processing
  • Enhance jetpack_forms_before_webhook_request filter to include feedback ID as a third parameter, enabling better tracking and conditional webhook processing
  • Pass feedback post ID through the webhook sending pipeline to provide context for filter implementations

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?

No, this PR only adds filter hooks for extensibility. No data tracking changes.

Testing instructions:

Testing the jetpack_forms_extra_webhooks filter:

Add the following code to your theme's functions.php:

add_filter( 'jetpack_forms_extra_webhooks', function( $webhooks, $form ) {
    // Add a test webhook programmatically
    $webhooks[] = array(
        'url' => 'https://webhook.site/your-unique-url',
        'webhook_id' => 'test-webhook-1',
        'enabled' => true,
    );
    return $webhooks;
}, 10, 2 );

Create a form, visit the frontend and submit it.

Verify that the webhook request is sent to your test webhook URL (or use the code below to just print to error log).

Testing the enhanced jetpack_forms_before_webhook_request filter:

Add the following code to your theme's functions.php:

add_filter( 'jetpack_forms_before_webhook_request', function( $data, $webhook_id, $feedback_id ) {
    // Log the feedback ID for verification
    error_log( 'Processing webhook ' . $webhook_id . ' for feedback ' . $feedback_id );
    
    // Optionally modify data based on feedback ID
    if ( $webhook_id === 'test-webhook-1' ) {
      $data['feedback_post_id'] = $feedback_id;
    }
    
    return $data;
}, 10, 3 );
  • Check the debug log to verify the feedback ID is being passed.
  • Verify that webhook payloads include the feedback_post_id field.

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. [Type] Task [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Package] Forms Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 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/forms-add-webhook-filter branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/forms-add-webhook-filter

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
Copy link
Contributor

github-actions bot commented Dec 8, 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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: January 6, 2026

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

@jp-launch-control
Copy link

jp-launch-control bot commented Dec 8, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 473/1397 (33.86%) -0.00% 4 💔

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell self-assigned this Dec 8, 2025
@CGastrell CGastrell changed the title Forms: Add webhook filters for programmatic webhook configuration Forms: Add filter for programmatic webhook configuration Dec 8, 2025
@CGastrell CGastrell requested a review from vianasw December 8, 2025 20:56
@vianasw vianasw force-pushed the add/forms-add-webhook-filter branch from d8e447f to b510517 Compare December 10, 2025 10:20
Copy link
Contributor

@vianasw vianasw left a comment

Choose a reason for hiding this comment

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

Looking good and working as expected.

@CGastrell CGastrell merged commit 53824f1 into trunk Dec 11, 2025
70 checks passed
@CGastrell CGastrell deleted the add/forms-add-webhook-filter branch December 11, 2025 14:00
@github-actions github-actions bot added this to the jetpack/15.4 milestone Dec 11, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants