Skip to content

Forms: Update MailPoet to use Feedback class #44852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

edanzer
Copy link
Contributor

@edanzer edanzer commented Aug 19, 2025

Proposed changes:

The new Feedback class was added just after we started MailPoet integration. It offers improved ways to work with form data. This PR updates the MailPoet_Integration class to use the Feedback class when checking for email, first name, last name, consent, and other form data.

Potential known issues:

  • @CGastrell found that on translated sites, the consent checkbox was not evaluating correctly during MailPoet submissions. Evaluating the consent value based on '1', 'true', or 'yes', as we do here is not sufficient. Assuming that's correct, we can fix that in this PR, or I prepped a separate PR with a suggested fix here.
  • This PR still uses the 'old' approach to check for first / last name ids, because the Feedback class doesn't have a way to get field values by ID. I prepped a PR for that here. Once merged, I can update that part of the code, too.
  • I find it odd that I still have to iterate over $fields to get the original $form configuration, including attributes. If we're using the Feedback class, it eems like there should be a way to do $feedback->get_form() to return the original form that generated a Feedback post.

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

Slack: p1755541020421639-slack-C052XEUUBL4

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

No.

Testing instructions:

This is a refactor, so the behavior should be the same before and after.

  • Prep: If you've tested this before, be sure to remove the MailPoet feature flag. You no longer need to add a MailPoet key to start adding contacts to your lists.
    Add a form to a page or post.
    • Required fields: Your form must have an email field. If you include a name field with 'First Name' label or 'firstname' id, that will be added to your lists. If you include a name field with 'Last Name' label or 'lastname' id, that will be added to your lists.
    • Enable MailPoet: Open the integration modal and install/activate MailPoet if needed. Complete MailPoet setup if prompted. Enable the MailPoet toggle, select a MailPoet list, and choose if you want consent field or not.
  • Test frontend submission: Go to frontend, submit, and confirm subscriber was added to MailPoet list.
  • Test consent: Test different consent states.
    • No consent field: contact will be added to MailPoet
    • Consent field with no checkbox: contact will be added to MailPoet
    • Consent field with 'checked' checkbox: contact will be added to MailPoet
    • Consent field with 'unchecked' checkbox: contact will not be added to MailPoet

@edanzer edanzer requested a review from a team August 19, 2025 18:55
@edanzer edanzer self-assigned this Aug 19, 2025
@edanzer edanzer added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Pri] Normal [Package] Forms labels Aug 19, 2025
Copy link
Contributor

github-actions bot commented Aug 19, 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 fix/forms-mailpoet-consent-value branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/forms-mailpoet-consent-value

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

Copy link
Contributor

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!

Copy link

jp-launch-control bot commented Aug 19, 2025

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@edanzer edanzer force-pushed the fix/forms-mailpoet-consent-value branch from 7278259 to 092c66f Compare August 20, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Contact Form [Package] Forms [Pri] Normal [Status] Needs Review This PR is ready for review. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant