Skip to content

Conversation

@edanzer
Copy link
Contributor

@edanzer edanzer commented Nov 14, 2025

Fixes FORMS-393

Proposed changes:

We added first and last variations for name. But we do not handle those properly post-submission. For example, before this PR, existing code would grab the first 'name' field of any kind and use that as the author name for a form response. So that means it would find first or last, and use that alone.

This PR adds proper handling of first and last names to the Feedback and Feedback_Author classes. Changes include:

  • getters for first and last name
  • updating the get_name method to return 'First Last' if possible or fall back to single name field as before
  • update Feedback_Author class to take in first and last name when instantiated
  • added tests

Caveats: There maybe languages/locales where names are reversed. We can figure out if/how to handle that separately.

Before
author-first-last-before

After
author-first-last-after

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

See linear issue.

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

No.

Testing instructions:

  • Add a form with first and last name variations, publish, and submit on frontend.
  • Go to form submissions and confirm we show the names together as author in the submission list and single submission view.
  • Confirm no regressions by adding a form with a single name field (no first/last name), and confirm that's still used as before.
  • Confirm PHP tests pass

@edanzer edanzer self-assigned this Nov 14, 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 Nov 14, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 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 update/forms-author-names branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/forms-author-names

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 [Feature] Contact Form [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Nov 14, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 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: December 2, 2025

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 Nov 14, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-feedback-author.php 40/40 (100.00%) 0.00% 0 💚
projects/packages/forms/src/contact-form/class-feedback.php 654/688 (95.06%) 0.03% 0 💚

Full summary · PHP report · JS report

)
);
}
// This name value is filtered upstream when class is instantiated.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feedback_Author->get_name() will now return 'First Last' if available, or fallback to 'Single Name' as before.

I added the filter here to ensure equivalence. We filter the single 'name' field in both places before we instantiate the Feedback_Author class class.

*/
public function get_author_last_name() {
return $this->author_data->get_last_name();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR does not use the two getters above, but I wanted to provide these for future handling, and we'll likely update our integration logic for MailPoet and Hostinger to leverage these methods.

@edanzer edanzer marked this pull request as ready for review November 14, 2025 19:40
'title' => 'Test Form',
'description' => 'This is a test form.',
),
"[contact-field label='Message' type='textarea' required='1'/]"
Copy link
Member

Choose a reason for hiding this comment

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

I think this should never work. Since the first and and last name fields are not specified in the form.

Copy link
Member

Choose a reason for hiding this comment

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

Since the form validation would prevent this from happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] In Progress [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [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.

3 participants