Skip to main content

React when a new membership tier is detected without a Benecaster mapping

Free Beginner Since v1.0.0

Fires when a new tier appears in the membership plugin without a matching row in benecaster_tier_map — both in real time (via on_tier_saved()) and from the daily sync for bridges that don’t implement on_tier_saved(). The built-in admin notice reacts to this action; this recipe adds supplementary Slack alerting so the admin doesn’t miss it. Debounce if needed — fires on every event where the mapping is absent.

Code

<?php
add_action( 'benecaster_tier_unmapped', function ( $tier_id, string $plugin_slug ): void {
    $message = sprintf(
        'New %s tier (ID: %s) detected — no Benecaster mapping found. Visit Benecaster settings to map it.',
        $plugin_slug,
        $tier_id
    );
    wp_remote_post( MY_SLACK_WEBHOOK_URL, [
        'body'    => wp_json_encode( [ 'text' => $message ] ),
        'headers' => [ 'Content-Type' => 'application/json' ],
    ] );
}, 10, 2 );

View on GitHub →

Hooks Used