We built DEV3 AI Comment & Community Moderator as a PHP plugin with a React admin app and a small front-end script. Rules run locally on every submission; the AI adds labels on top.
Key design decisions
- A one-way ratchet. Statuses are ranked live < held < spam < trash. The policy can move an item down that list, never up, and flags never move content at all. Approving and deleting are left to people.
- Strictest action wins. Each rule (links, blocklist, posting rate, duplicates, personal data, profanity, Akismet) and each AI label (spam, toxicity, harassment, off-topic, personal data) has a threshold and an action. The decision is the most severe action that fired, with every reason recorded.
- Screening before save, with a time limit. In sync mode the classifier runs inside
pre_comment_approved with an 8-second timeout and no retries. If the API fails, the rules decide now and the item is queued for a background re-check.
- Humans win. When a moderator changes an item's status, it is marked reviewed and the AI never moves it again, though a later AI decision is still recorded.
- Native status functions. Comments and reviews move through
wp_spam_comment() and friends; bbPress topics and replies through bbPress's own pending and spam statuses, so other plugins see normal events.
- Privacy by default. IP addresses are stored only as hashes, personal data is masked before AI requests, and records can be exported, erased and pruned.
Architecture
One pipeline screens WordPress comments, WooCommerce product reviews and bbPress topics and replies, and writes a moderation record with labels, reasons, sentiment and a history of who moved what. The queue has views for needs review, held, spam and flagged-but-live, bulk actions and a drawer with a reply composer. The Google Gemini API (gemini-2.5-flash) also drafts brand-voice replies and discussion summaries, which stay drafts until accepted. On the front end, an optional "be kind" nudge checks a comment locally (and optionally with AI) before it is posted and lets the writer choose. With AI off, rules, lexicon sentiment, reply templates and the local nudge all still work. The API client and settings come from a shared core used across DEV3's plugins.