Skip to main content

benecaster_license_plan_upgraded

Action Premium

Fires immediately after a one-click plan upgrade (Settings → Account → Plan changes → Upgrade plan) is confirmed by the license server — REST\LicenseController::upgrade() fires it synchronously on the same request that confirmed the change, before the next daily LicenseValidationCron tick would otherwise surface it. Only fires when the plan actually changed; a confirmed call that returns the plan already held does not fire it.

This is a narrower, faster sibling of benecaster_license_plan_changed, which fires from the daily validation cron on any plan change, upgrade or otherwise. Use this hook when a listener needs to react the moment the customer confirms an upgrade in the dialog — a notice, an analytics event, an email — rather than waiting for the next cron cycle.

React to a One-Click Plan Upgrade

Premium Beginner

benecaster_license_plan_upgraded fires synchronously the moment a podcaster confirms a one-click plan upgrade in Settings → Account → Plan changes — before the next daily validation cron would otherwise surface the change. Use it when a listener needs to react immediately (an in-app notice, an analytics event, an email) rather than waiting for the next cron tick.

benecaster_license_plan_changed is the broader, slower sibling: it fires from the daily LicenseValidationCron on any plan change, upgrade or otherwise, and is what you want if you need to catch every transition regardless of cause. This recipe shows both side by side so you can pick the one that matches when you actually need to know.

⚠ Neither hook fires on a refused upgrade — a WP_Error from the confirmation dialog (an interval mismatch, a blocked payment method, a network failure) never reaches either action.

<?php
// Fires the instant an upgrade is confirmed — before the next cron tick.
add_action( 'benecaster_license_plan_upgraded', function ( string $old_plan, string $new_plan ): void {
    my_addon_log_event( 'plan_upgraded', [
        'from' => $old_plan,
        'to'   => $new_plan,
    ] );
}, 10, 2 );

// Fires from the daily validation cron on ANY plan change — upgrade,
// downgrade, or a server-side correction — not just the one-click flow.
add_action( 'benecaster_license_plan_changed', function ( string $from, string $to ): void {
    if ( '' === $to ) {
        // Licence went invalid or its site token was revoked.
        my_addon_clear_cached_capabilities();
        return;
    }

    my_addon_refresh_cached_capabilities( $to );
}, 10, 2 );

View on GitHub →

Parameters

Name Type Default Description
$old_plan string The plan slug immediately before this upgrade.
$new_plan string The plan slug the license server just confirmed.

Notes

Does not replace benecaster_license_plan_changed. A listener that needs to catch every plan transition regardless of cause (upgrade dialog, server-side change, downgrade signal) should still watch that hook; this one only ever fires from the one-click upgrade confirmation path.

Never fires on a refusal. A refused upgrade (interval mismatch after retry, payment method blocked, a network failure) surfaces as a WP_Error to the confirmation dialog and this hook does not fire — there is no "upgrade attempted but failed" action, only the successful transition.

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