benecaster_membership_price_created
Fires after a billing cadence is added to a built-in membership tier. Two paths reach it: creating a tier with a prices[] array via POST /membership-tiers, and reconciliation on PUT /membership-tiers/{id} when the payload contains a cadence that is not yet stored.
Benecaster hooks this action itself to mint the Stripe Price for the cadence. The row therefore exists with null stripe_price_id_test and stripe_price_id_live at the moment this hook fires — do not assume a Stripe ID is present in a callback on this hook.
Note that changing the amount on an existing cadence does not fire this hook. That path nulls the Stripe IDs and re-mints against the same row.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$price_id |
int |
— | ID of the newly created price record. |
$price |
array |
— | The full cadence: `cadence_label`, `interval_unit`, `interval_count`, `amount_cents`, `currency`, `is_default`, `sort_order`, and the two Stripe ID columns (null at this point). |
$tier_id |
int |
— | ID of the tier the cadence belongs to. |
Example
// Mirror new cadences into an external catalogue.
add_action( 'benecaster_membership_price_created', function ( int $price_id, array $price, int $tier_id ) {
my_catalogue_add_plan( [
'tier_id' => $tier_id,
'price_id' => $price_id,
'label' => $price['cadence_label'],
'amount' => $price['amount_cents'] / 100,
'currency' => $price['currency'],
'every' => $price['interval_count'] . ' ' . $price['interval_unit'],
] );
}, 10, 3 );
Notes
Runs on every cadence during a bulk tier create, once per cadence. If your callback is expensive, batch on shutdown rather than doing the work inline.
Need this built rather than just documented? See our services →