Skip to main content
The MainWP Comments Add-on registers five abilities in the mainwp-comments category. All use the mainwp/ namespace on your MainWP Dashboard. Use these abilities when a script, AI assistant, or MCP client needs to review or moderate comments across your child sites. For example, you can list pending comments on your client sites, approve the legitimate ones, and move spam to Trash. Two abilities read live comments from child sites, one reads the recent comments stored at the last sync, one applies reversible moderation actions, and one previews or permanently deletes trashed comments.

What You’ll Learn

  • List comments from your child sites with status, keyword, date, and post filters
  • Read one comment from a child site
  • Read the recent comments saved at the last sync without contacting child sites
  • Approve, unapprove, spam, unspam, trash, and restore comments with status checks
  • Preview and confirm the permanent deletion of trashed comments

Prerequisites

  • WordPress 6.9 or later on the MainWP Dashboard site
  • MainWP Dashboard with Abilities API support; use version 6.2 or later for the input_json examples below
  • Comments Add-on 6.1.0 or later, active in MainWP Dashboard
  • A current MainWP Child build supporting the Comments v2 contract on target sites for mainwp/get-comment-v1, mainwp/moderate-comments-v1, and mainwp/delete-comments-permanently-v1. An older or unreadable response fails rather than confirming an action.
  • An authenticated WordPress user with permission to use MainWP abilities and access to the Comments Add-on
Team Control restrictions apply. Each ability checks the Dashboard abilities permission, the user’s access to the Comments Add-on, and the user’s access to every selected site. Use an Application Password or the authentication methods in the Abilities API overview. The examples use an Application Password.

Available Abilities

Discover the abilities and their full input and output schemas:
The three read abilities are marked readonly: true. mainwp/moderate-comments-v1 is marked readonly: false, destructive: false, and idempotent: true. mainwp/delete-comments-permanently-v1 is marked destructive: true and idempotent: false. Comments returned by these abilities never include the author’s email address, IP address, or URL.

List Comments

Ability: mainwp/list-comments-v1
Method: GET
The ability asks each selected child site for its comments. All inputs are optional. Without input, it reads up to 50 approved and pending comments from each of the first 100 sites you can access.
Example response:
  • comment_date is a Unix timestamp. An unusable timestamp can fail that site’s read.
  • post_id is 0 when the comment is not attached to a post.
  • site_results has one entry per site on the page. A failed site does not stop the others, and partial is true when some sites succeeded and some failed.
  • pagination pages over sites, not comments. When has_more is true, request the next page.
Date filters use exclusive midnight boundaries: to read one day, use the following day as end_date. Equal start and end dates return no matches. When every selected site fails, the ability returns mainwp_comments_child_error with HTTP 502.

Get a Comment

Ability: mainwp/get-comment-v1
Method: GET
Reads one comment directly from the child site. Both inputs are required positive integers: site_id and comment_id.
Example response:
comment_status is approved, pending, spam, trash, or post-trashed (the comment’s post is in Trash). observed_at is the UTC time the Dashboard received the result. Use this ability to check a comment’s current status before you moderate it. A comment without an attached post can appear in list results as post_id: 0, but the current v2 detail reader rejects it.

List Synced Recent Comments

Ability: mainwp/list-synced-recent-comments-v1
Method: GET
Returns the recent comments the Dashboard stored during the last completed site sync. It does not contact child sites, so it is fast, but the data is only as current as the last sync. Each sync stores at most five approved and five pending comments per site. All inputs are optional.
The response includes source (always dashboard_sync_cache), snapshot_limit_per_status (always 5), comments, site_results, total, partial, and pagination. Each comment also carries site_id and last_sync, the UTC time of the sync that stored it. Each entry in site_results has a status: When possibly_truncated is true for a site, a selected status reached the five-comment limit, so the site may have more comments. Use mainwp/list-comments-v1 to read them live.

Moderate Comments

Ability: mainwp/moderate-comments-v1
Method: POST
Applies one reversible action to up to 100 comments on one site. Each item names a comment and the status you expect it to have. The child site changes a comment only when its current status matches expected_status, so a comment that someone else moderated in the meantime is not changed by mistake.
Example response:
The batch is not all-or-nothing. results has exactly one entry for every requested comment, with one of these outcomes:
Keep WordPress Trash enabled on target sites before using the trash moderation action. If EMPTY_TRASH_DAYS is 0, WordPress can delete a comment permanently instead of moving it to Trash. The current Child v2 handler calls WordPress’s trash action and cannot guarantee reversibility in that configuration. A failed or unknown response does not prove that the comment still exists.
Read each comment again after a failed or unknown result before deciding whether to retry. Repeating an already applied action can return a conflict or not-found result. Successful changes are recorded in Network Activity.

Permanently Delete Comments

Ability: mainwp/delete-comments-permanently-v1
Method: POST
Permanent deletion cannot be undone. Run a preview first and delete only after the user explicitly confirms.
Deletes up to 100 comments on one site. Only comments in Trash can be deleted, so every item must use "expected_status": "trash". Set exactly one of dry_run and confirm to true. Sending both as true or both as false returns mainwp_comments_confirmation_required with HTTP 400.
1

Preview the deletion

Send the request with "dry_run": true and "confirm": false. Comments that would be deleted return the outcome would_delete.
2

Confirm the deletion

After the user approves the preview, send the same items with "dry_run": false and "confirm": true.
Example response:
eligible counts the comments that were in Trash before processing, and deleted counts the comments confirmed gone afterward. Each result has one of these outcomes: would_delete (preview only), deleted, conflict (the comment is not in Trash), not_found, or failed.

Handle Errors

WordPress can reject invalid input against the public schema before the Add-on callback runs. MainWP Dashboard also returns HTTP 401 for unauthenticated requests.