ReaderFlag – Report This Content Button

Description

ReaderFlag puts a “Report this content” button on your posts, pages and public custom post types. A visitor picks a reason, adds an optional message, and sends it. You see every report in a list in wp-admin, change its status, and get an email for each new one (you can turn the emails off).

Features:

  • Popup, inline or link-only form. The popup is a native dialog with keyboard support and focus handling.
  • Works without JavaScript: the form falls back to a normal page that posts to the server.
  • Safe behind page caches (Batcache, edge caches): the form fetches a fresh token by POST when it opens, so no token is ever cached.
  • Reasons are editable. Name, email and message fields are each required, optional or hidden.
  • Spam protection with no setup: a honeypot, a signed single-use token, a minimum fill time and an optional built-in math question. You can switch to Cloudflare Turnstile, hCaptcha or Google reCAPTCHA (v2 or v3).
  • Reports list in wp-admin with filters, sorting, bulk actions (reviewed, resolved, dismissed, delete) and a CSV export.
  • A count column and a meta box on the post edit screens.
  • Block, shortcode, template function and action hook for placement.
  • Button and form styling in the settings, with a live preview. Everything is driven by CSS variables.
  • Privacy tools: personal data export and erase, suggested privacy policy text, an optional retention period and optional IP hashing.
  • Ready for translation on translate.wordpress.org.

The plugin makes no request to any other site unless you save the keys for a captcha service. See “External services” below.

External services

The plugin works fully on its own. If you choose a captcha service in the settings and save its keys, the visitor’s browser loads that service’s script, and your server sends it the visitor’s response token to check it. Nothing is sent before you save the keys, and the script loads only when a visitor opens the form. Use only the one you choose.

Cloudflare Turnstile

Used when the captcha is set to Turnstile and the site key and secret key are saved.

  • What is sent: the visitor’s browser loads https://challenges.cloudflare.com/turnstile/v0/api.js when the form opens. The browser sends the usual request data (IP address, browser details) to Cloudflare. When the report is sent, your server posts the Turnstile response token and the secret key to https://challenges.cloudflare.com/turnstile/v0/siteverify.
  • Terms of service: https://www.cloudflare.com/website-terms/
  • Privacy policy: https://www.cloudflare.com/privacypolicy/

hCaptcha

Used when the captcha is set to hCaptcha and the site key and secret key are saved.

  • What is sent: the visitor’s browser loads https://js.hcaptcha.com/1/api.js when the form opens and sends the usual request data to hCaptcha. When the report is sent, your server posts the hCaptcha response token and the secret key to https://api.hcaptcha.com/siteverify.
  • Terms of service: https://www.hcaptcha.com/terms
  • Privacy policy: https://www.hcaptcha.com/privacy

Google reCAPTCHA (v2 and v3)

Used when the captcha is set to reCAPTCHA v2 or v3 and the site key and secret key are saved.

  • What is sent: the visitor’s browser loads https://www.google.com/recaptcha/api.js when the form opens and sends the usual request data to Google. reCAPTCHA also collects information about the visitor’s use of the page. When the report is sent, your server posts the response token and the secret key to https://www.google.com/recaptcha/api/siteverify.
  • Terms of service: https://policies.google.com/terms
  • Privacy policy: https://policies.google.com/privacy

Privacy

When a visitor sends a report, the plugin stores the reason, the optional message, the optional name and email address, the reported post, the time, and the user account if the visitor is logged in. It stores a one-way hash of the IP address to limit abuse, unless you set “Visitor IP address” to “Do not store it” in the settings. The IP address itself is not stored.

  • Reports are kept until you delete them, or for the number of days you set in “Delete reports after (days)”.
  • The plugin adds a personal data exporter and an eraser to the WordPress privacy tools (Tools > Export Personal Data and Erase Personal Data), matched by email address.
  • It adds suggested text for your privacy policy page.
  • If you use a captcha service, the visitor’s browser talks to that service. See “External services”.
  • Removing the plugin keeps your reports unless you turn on “Delete all reports and settings when the plugin is deleted” in the settings first.

Developer hooks

All hooks are prefixed rtcb_.

Filters

  • rtcb_reasons( array $reasons ): the list of reasons shown in the form. Each item is array( 'key' => string, 'label' => string ). Items without a non-empty string key and a string label are dropped.
  • rtcb_form_fields( array $fields ): how each optional field behaves. An array with the keys message, name and email, each required, optional or hidden.
  • rtcb_validate_report( WP_Error $errors, array $row ): add validation errors before a report is saved. $row holds post_id, reason_key, reason_label, message, reporter_name, reporter_email, user_id, ip_hash and status. Add an error with the code reason, message, name, email or captcha to mark that field, or any other code for a form-level error. Only the error codes are used: the visitor sees the plugin’s own generic message for any code that is not one of those fields, and the message text you pass to WP_Error is never shown or stored. Return the WP_Error.
  • rtcb_should_display( bool $show, int $post_id, string $context ): return false to hide the button. $context is auto, shortcode, hook or block.
  • rtcb_capability( string $capability ): the capability needed to see and handle reports. Default moderate_comments.
  • rtcb_client_ip( string $ip ): the visitor’s IP address, for sites behind a proxy. Starts as a validated REMOTE_ADDR. Return a valid IP address, or an empty string.
  • rtcb_notification_email( array $args, array $row ): the notification before it is sent. $args has to (array of addresses), subject, message (plain text) and headers (array). $row is the report data. Return an empty to to send nothing.
  • rtcb_min_fill_seconds( int $seconds ): the shortest time, in seconds, between opening the form and sending it. Default 3.

Actions

  • rtcb_before_save_report( array $row ): fires after validation passes, just before the report is saved.
  • rtcb_report_saved( int $id, array $row ): fires after the report is saved, before the notification email is sent.
  • rtcb_render_button( array $args ): renders the button in place. $args may hold post_id, mode, text and align.

Template function

rtcb_the_button( array $args = array() ) echoes the button. It is the same as `do_action( 'rtcb_render_button', $args )`. Arguments: `post_id` (default: the current post), `mode` (`popup`, `inline` or `link`), `text` (button text) and `align` (`left`, `center` or `right`).

Shortcode

[report_this_content] with the attributes `post_id` (default: the current post), `mode` (`popup`, `inline` or `link`) and `text` (button text). Example: `[report_this_content mode="inline" text="Flag this"]`.

Block

The “ReaderFlag Report Button” block has the same options (mode, text, alignment) in the block sidebar.

Source code and build

All PHP, CSS and front-end JavaScript ship unminified. The block editor script blocks/report-button/build/index.js is compiled from the source in blocks/report-button/src/, which ships in the plugin too, with @wordpress/scripts. To rebuild it, run npm install and then npm run build in the plugin folder (the command is in the included package.json).

Screenshots

Blocks

This plugin provides 1 block.

  • ReaderFlag Report Button A button that lets visitors report this content.

Installation

  1. Upload the plugin folder to /wp-content/plugins/, or install it from the Plugins screen.
  2. Activate it through the Plugins screen.
  3. Open Reports > Settings to choose where the button appears, the reasons, the fields and the look.
  4. Reports arrive under Reports in the admin menu.

FAQ

Where does the button appear?

By default after the content of posts. In Reports > Settings you can place it before the content, after it, both, or turn auto-placement off and place it yourself with the block, the shortcode [report_this_content], or rtcb_the_button() in a theme template.

Does it work with a page cache such as Batcache or an edge cache?

Yes. A cached page never holds a token or a nonce. When a visitor opens the form, the script asks the server for a token with a POST request to admin-ajax.php. POST requests are not cached, and the token response is sent with no-store headers. The token is signed, tied to the post and the user, valid for two hours and accepted once.

What is “Separate page (for strict caches)”?

It is a setting for the no-JavaScript fallback. Normally the fallback form is the post’s own address with a flag in the query string. A cache that ignores query strings could serve one visitor’s form state to another. Choose “Separate page (for strict caches)” and the fallback form is served from admin-post.php, which is never cached.

Does it work without JavaScript?

Yes. The trigger is a plain link to a page with the form. A visitor with JavaScript off fills it in and sends it as an ordinary form. Turnstile, hCaptcha and reCAPTCHA need their script, so with one of them selected a visitor without JavaScript sees a note to turn JavaScript on instead of the form. Choose “None” or the math question if the form must work without JavaScript.

Which captchas are supported?

None, a built-in math question (digits in English or Devanagari are accepted), Cloudflare Turnstile, hCaptcha, Google reCAPTCHA v2 checkbox and Google reCAPTCHA v3. A third-party captcha is used only after you save its site key and secret key, and its script loads only when a visitor opens the form. Secret keys are stored separately from the other settings and are never printed back in the settings screen.

How do I style the button and the form?

Use the Styles tab, or override these CSS variables in your theme (set them on .rtcb):

  • --rtcb-btn-bg, --rtcb-btn-text, --rtcb-btn-border
  • --rtcb-btn-hover-bg, --rtcb-btn-hover-text
  • --rtcb-btn-radius, --rtcb-form-radius
  • --rtcb-popup-width
  • --rtcb-accent, --rtcb-ink, --rtcb-surface, --rtcb-line, --rtcb-error
  • --rtcb-overlay

For other changes, add CSS in Appearance > Customize > Additional CSS (or Styles > Additional CSS in the Site Editor). You can also switch the plugin’s stylesheet off in the settings and write your own.

Who can see the reports?

Users who have the moderate_comments capability (editors and administrators by default). Only administrators can change the settings. Use the rtcb_capability filter to change who moderates.

Can I add my own rules, reasons or fields?

Yes. See “Developer hooks” below.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“ReaderFlag – Report This Content Button” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.0

  • First release.