Skip to content

Forms: Keep response notes private to people who manage responses - #55021

Open
enejb wants to merge 7 commits into
trunkfrom
update/forms-notes-hold-status
Open

enejb wants to merge 7 commits into
trunkfrom
update/forms-notes-hold-status

Conversation

@enejb

@enejb enejb commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

Response notes (behind the jetpack_forms_notes_enable filter, not released yet) are core comments on the feedback post. This changes how they are stored and shown:

  • Notes on feedback posts are now stored with the hold status instead of being approved, and moderators no longer get a "comment awaiting moderation" email for them. Only people who can manage responses can leave notes, so a spam verdict from Akismet doesn't apply: notes stay held when they're created, and are put back on hold if Akismet's "Check for Spam" recheck marks them as spam.
  • Notes get their own comment type, jetpack_form_note. Like core's note type, comment queries leave it out unless they ask for it, so notes no longer show up in wp-admin › Comments, its pending counts, the admin bar, or the Activity dashboard widget.
  • The notes panel in the Responses dashboard asks for notes of that type with status all, so it keeps showing a note even if a moderator approves it.
  • Deleting a note from the panel deletes it outright. Notes don't show in wp-admin › Comments, so a trashed note couldn't be restored from anywhere.
  • Notes are included in personal data exports and erasures, through core's comment exporter and eraser limited to notes. Core's own ones skip them because of the comment type.

Related product discussion/links

  • N/A

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

No.

Testing instructions

Setup: a site with Jetpack Forms active and notes turned on. The second filter keeps test submissions out of spam, so new responses land in the inbox:

add_filter( 'jetpack_forms_notes_enable', '__return_true' );
add_filter( 'jetpack_contact_form_is_spam', '__return_false', 99 );

Rehearsals

Run these from Tools → Rehearsal on any JN site, in this order. The first one needs a published page at /rehearsal-notes-form/ containing a form with a Name field:

wp post create --post_type=page --post_status=publish --post_title="Rehearsal notes form" --post_name=rehearsal-notes-form --post_content='[contact-form][contact-field label="Name" type="name" required="1"/][contact-field label="Message" type="textarea"/][/contact-form]'

The first rehearsal submits a response, adds a note, reopens the response to check the note is still there, then checks the note isn't listed in wp-admin Comments. The second one, run as an author, checks that the note from the first isn't in the comments the author can read through the REST API. The third adds a note, deletes it from the panel, and checks it isn't in the Trash. The fourth, run as an author after the first, checks that wp-admin Comments filtered to notes lists none of them.

Before this PR (Jetpack 16.5-a.5), the first fails at step 18, because the note shows up in wp-admin Comments, and the second fails at step 3. When Akismet marks the note as spam instead, the first one fails at step 15, because the note is gone after reopening the response. On the previous commit of this PR, which moved deleted notes to the Trash, a deleted note is listed in the Trash view the third one checks. The fourth fails at step 3 on that commit too.

Rehearsal: Forms: A note on a response stays in its notes panel and out of wp-admin Comments (changes the site)

Rehearsal b22c260 · 19 steps · covers packages/forms
Last run: Passed on WordPress 7.1.5 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Jetpack 16.5-a.5, run #19, 2026-11-27.
View or install this rehearsal · JSON · Playwright test (links work while freely-silky-stork.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 2,
    "requires": [
        "jetpack"
    ],
    "covers": [
        "packages/forms"
    ],
    "viewport": "desktop",
    "timeout": 30000,
    "steps": [
        {
            "goto": "/rehearsal-notes-form/"
        },
        {
            "expect": "form.contact-form button[type=submit]",
            "toBeVisible": true
        },
        {
            "fill": "form.contact-form input[type=text]",
            "value": "Rehearsal {{run}}"
        },
        {
            "click": "form.contact-form button[type=submit]"
        },
        {
            "expectText": "Thank you for your response."
        },
        {
            "goto": "/wp-admin/admin.php?page=jetpack-forms-responses-wp-admin&p=%2Fresponses%2Finbox"
        },
        {
            "click": "[role=checkbox][aria-label=\"Rehearsal {{run}}\"]"
        },
        {
            "expect": ".jp-forms__feedback-comments-heading",
            "toContainText": "Notes"
        },
        {
            "fill": ".jp-forms__feedback-comments-form textarea",
            "value": "Rehearsal note {{run}}"
        },
        {
            "click": ".jp-forms__feedback-comments-form button:has-text(\"Add note\")"
        },
        {
            "expect": ".jp-forms__feedback-comments-list",
            "toContainText": "Rehearsal note {{run}}"
        },
        {
            "goto": "/wp-admin/admin.php?page=jetpack-forms-responses-wp-admin&p=%2Fresponses%2Finbox"
        },
        {
            "click": "[role=checkbox][aria-label=\"Rehearsal {{run}}\"]"
        },
        {
            "expect": ".jp-forms__feedback-comments-heading",
            "toContainText": "Notes"
        },
        {
            "expect": ".jp-forms__feedback-comments-list",
            "toContainText": "Rehearsal note {{run}}"
        },
        {
            "goto": "/wp-admin/edit-comments.php?comment_status=all"
        },
        {
            "expect": "h1",
            "toContainText": "Comments"
        },
        {
            "expect": "#the-comment-list",
            "toContainText": "Rehearsal note {{run}}",
            "not": true
        },
        {
            "expectNoConsoleErrors": true
        }
    ]
}

Rehearsal: Forms: Authors cannot read notes on responses

Rehearsal b946f3b · 3 steps · covers packages/forms
Last run: Passed on WordPress 7.1.5 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Jetpack 16.5-a.5, run #20, 2026-11-27.
View or install this rehearsal · JSON · Playwright test (links work while freely-silky-stork.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 1,
    "requires": [
        "jetpack"
    ],
    "covers": [
        "packages/forms"
    ],
    "role": "author",
    "steps": [
        {
            "goto": "/wp-json/wp/v2/comments?per_page=100"
        },
        {
            "expect": "body",
            "toContainText": "\"author_name\""
        },
        {
            "expect": "body",
            "toContainText": "Rehearsal note",
            "not": true
        }
    ]
}

Rehearsal: Forms: Deleting a note from a response removes it for good (changes the site)

Rehearsal 4f7da57 · 18 steps · covers packages/forms
Last run: Passed on WordPress 7.1.5 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Jetpack 16.5-a.5, run #26, 2026-11-27.
View or install this rehearsal · JSON · Playwright test (links work while freely-silky-stork.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 2,
    "requires": [
        "jetpack"
    ],
    "covers": [
        "packages/forms"
    ],
    "viewport": "desktop",
    "timeout": 30000,
    "steps": [
        {
            "goto": "/rehearsal-notes-form/"
        },
        {
            "expect": "form.contact-form button[type=submit]",
            "toBeVisible": true
        },
        {
            "fill": "form.contact-form input[type=text]",
            "value": "Rehearsal {{run}}"
        },
        {
            "click": "form.contact-form button[type=submit]"
        },
        {
            "expectText": "Thank you for your response."
        },
        {
            "goto": "/wp-admin/admin.php?page=jetpack-forms-responses-wp-admin&p=%2Fresponses%2Finbox"
        },
        {
            "click": "[role=checkbox][aria-label=\"Rehearsal {{run}}\"]"
        },
        {
            "expect": ".jp-forms__feedback-comments-heading",
            "toContainText": "Notes"
        },
        {
            "fill": ".jp-forms__feedback-comments-form textarea",
            "value": "Rehearsal deleted note {{run}}"
        },
        {
            "click": ".jp-forms__feedback-comments-form button:has-text(\"Add note\")"
        },
        {
            "expect": ".jp-forms__feedback-comments-list",
            "toContainText": "Rehearsal deleted note {{run}}"
        },
        {
            "click": ".jp-forms__feedback-comments-comment:has-text(\"Rehearsal deleted note {{run}}\") >> button[aria-label=\"Note options\"]"
        },
        {
            "click": "[role=menuitem]:has-text(\"Delete\")"
        },
        {
            "expect": ".jp-forms__feedback-comments",
            "toContainText": "Rehearsal deleted note {{run}}",
            "not": true
        },
        {
            "goto": "/wp-admin/edit-comments.php?comment_status=trash&comment_type=jetpack_form_note"
        },
        {
            "expect": "h1",
            "toContainText": "Comments"
        },
        {
            "expect": "#the-comment-list",
            "toContainText": "Rehearsal deleted note {{run}}",
            "not": true
        },
        {
            "expectNoConsoleErrors": true
        }
    ]
}

Rehearsal: Forms: Authors cannot list notes in wp-admin Comments

Rehearsal 459bbaf · 3 steps · covers packages/forms
Last run: Passed on WordPress 7.1.5 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Jetpack 16.5-a.5, run #34, 2026-11-27.
View or install this rehearsal · JSON · Playwright test (links work while freely-silky-stork.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 1,
    "requires": [
        "jetpack"
    ],
    "covers": [
        "packages/forms"
    ],
    "role": "author",
    "steps": [
        {
            "goto": "/wp-admin/edit-comments.php?comment_status=all&comment_type=jetpack_form_note"
        },
        {
            "expect": "h1",
            "toContainText": "Comments"
        },
        {
            "expect": "#the-comment-list",
            "toContainText": "Rehearsal note",
            "not": true
        }
    ]
}

Manual checks

The rehearsals cover the first half of step 1, step 5 for administrators, and step 3's listing as an author. These steps cover the rest. You'll need at least one form response, plus an editor and an author user.

  1. As an administrator, go to Jetpack → Forms → Responses, open a response, and add a note.
    • The note appears, and is still there after reloading the page and opening the response again.
    • In the network tab, the POST /wp/v2/comments response has "status": "hold" and "type": "jetpack_form_note".
  2. Log in as an editor and add a note to the same response. Both notes show up for the editor and the administrator.
  3. Logged in as an author, request /wp-json/wp/v2/comments?post=<response ID> and /wp-json/wp/v2/comments/<note ID> with the REST nonce. Both return 403.
  4. Logged out, request the same two URLs. Both return 401.
  5. Go to Comments in wp-admin, as an administrator and as an author. The notes are not listed under All or Pending, the pending count doesn't include them, and they don't appear in the Activity widget on the Dashboard.
  6. Leave a comment on a regular post and confirm it is approved and listed as before.
  7. Go to Tools › Export Personal Data and request an export for the editor's email. The export includes their notes. Tools › Erase Personal Data anonymizes them.

Unit tests cover the read check for each role and the stored approval status:

cd projects/packages/forms
composer phpunit -- --filter 'test_feedback_notes|test_comment_queries_exclude|test_note_comment_type|test_moderators_are_not|test_notes_privacy'

@enejb enejb self-assigned this Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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-notes-hold-status branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/forms-notes-hold-status

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 commented Nov 16, 2026 •

Copy link
Copy Markdown
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 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!

@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 Nov 16, 2026
@jp-launch-control

jp-launch-control Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/dashboard/components/feedback-comments/index.tsx 0/94 (0.00%) 0.00% 1 ❤️‍🩹
projects/packages/forms/src/dashboard/constants.ts 20/20 (100.00%) 0.00% 0 💚
projects/packages/forms/src/contact-form/class-contact-form-endpoint.php 1118/1260 (88.73%) 0.17% -2 💚
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 823/1659 (49.61%) 1.89% -10 💚

Full summary · PHP report · JS report

@enejb
enejb marked this pull request as ready for review November 16, 2026 18:04
@enejb enejb added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Nov 16, 2026
@enejb enejb changed the title Forms: Store response notes as held and limit reading them to response managers Forms: Keep response notes private to people who manage responses Nov 16, 2026
@enejb
enejb force-pushed the update/forms-notes-hold-status branch from db86dea to 3ea4874 Compare November 25, 2026 18:45
@enejb
enejb force-pushed the update/forms-notes-hold-status branch from 3ea4874 to 9052ec1 Compare November 27, 2026 21:51

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant