Skip to main content

Moderate or audit-log every Supporter Wall message

Premium Intermediate

The Supporter Wall lets subscribers write a short “Why I support” message that is displayed publicly alongside their name. It is the one place on a podcaster’s site where a subscriber writes something everyone else can read, which makes it the one place worth watching.

This hook fires every time a subscriber’s message is saved, so an add-on can screen it before anyone sees it, copy it to a CRM, or keep a record of what changed and when.

When to Use This

Automatic moderation is the common case — checking new messages against a word list or a moderation service and blanking anything flagged. It is also useful for compliance, where a history of what was published and when is worth keeping, and for mirroring the message into a system outside WordPress.

It fires on clears as well as writes. A subscriber deleting their message triggers the hook with an empty message, so check for that first — there is nothing to moderate, and a moderation service called with an empty string is a wasted request.

Changing the Message From Inside the Hook

Blanking a flagged message from inside your handler does not trigger the hook again. This is deliberate: without it, every moderation handler that edits a message would trigger itself and loop forever.

The trade-off is worth knowing. Because a direct write is silent, other add-ons listening for changes never learn about it. That is exactly what you want for moderation — one handler quietly cleaning up. It is not what you want from a scheduled job clearing messages in bulk, where other listeners probably should be told. In that case, save the message the same way the subscriber’s own account page does, and every listener including yours sees it normally.

Related

Code

<?php
add_action( 'benecaster_subscriber_wall_message', function ( int $user_id, string $message ): void {
    if ( '' === $message ) {
        return; // Nothing to moderate on a clear.
    }
    if ( my_profanity_filter_flags( $message ) ) {
        // Blank the meta immediately, then notify the podcaster.
        // NOTE: calling update_user_meta directly here does NOT re-fire benecaster_subscriber_wall_message.
        // The action only fires when the write goes through SupporterWallManager::set_subscriber_message().
        // This is intentional — it prevents infinite loops in moderation hooks.
        update_user_meta( $user_id, '_benecaster_subscriber_wall_message', '' );
        // Plain wp_mail() is deliberate: operator alert to the site's own admin address.
        // Use benecaster_mail() for anything a podcaster or subscriber reads.
        wp_mail(
            get_option( 'admin_email' ),
            'Flagged Supporter Wall message',
            sprintf( 'User %d wrote a message that tripped the profanity filter and was auto-cleared.', $user_id )
        );
    }
}, 10, 2 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →