React to a One-Click Plan Upgrade
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.
Code
<?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 );
Hooks Used
Need this built rather than just documented? See our services →