Skip to main content

Moderate or audit-log every Supporter Wall message

Free Intermediate Since v1.0.0

SupporterWallManager::set_subscriber_message() fires benecaster_subscriber_wall_message after every write of the subscriber’s “Why I support” message — including empty-value clears. Use to auto-moderate flagged content, mirror the message to an external CRM, or track message-change history for compliance. Note: writing _benecaster_subscriber_wall_message directly via update_user_meta() inside the hook does NOT re-fire the action (avoiding infinite loops), but means bulk-clearing from a scheduled job should call SupporterWallManager::set_subscriber_message() if other listeners need to see the change.

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', '' );
        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