Restrict Content Pro
rcp_update_membership()
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro
Updates an existing membership record in the database. Requires Restrict Content Pro 3.0 or later.
This function loads the membership with rcp_get_membership() and calls RCP_Membership::update() on that object. You can also call $membership->update( $data ) directly if you already have an RCP_Membership instance.
For workflows that send emails, adjust gateway subscriptions, or run core hooks, prefer dedicated methods on RCP_Membership (for example activate(), renew(), cancel(), expire(), set_expiration_date()) instead of only changing raw database fields.
Parameters
$membership_id (int) — ID of the membership to update.
$data (array) — Columns to change. Only include keys you want to update. Supported keys match rcp_add_membership(), including:
customer_id,Âuser_id,Âobject_id,Âobject_typecurrency,Âinitial_amount,Ârecurring_amountcreated_date,Âtrial_end_date,Ârenewed_date,Âcancellation_date,Âexpiration_dateauto_renew,Âtimes_billed,Âmaximum_renewals,Âstatusgateway,Âgateway_customer_id,Âgateway_subscription_idsignup_method,Âsubscription_key,Ânotes,Âupgraded_from,Âdisabled
Behavior notes
expiration_date — Pass a MySQL datetime string, orÂnone for lifetime (no expiration).status — UseÂpending,Âactive,Âcancelled, orÂexpired. LegacyÂfree is converted toÂactive. SettingÂstatus toÂactive also applies the membership level’s user role when the update succeeds.notes — Updates the stored notes field. To append a note without replacing existing text, use RCP_Membership::add_note().- Changes to certain fields (such asÂ
status,Âexpiration_date, and gateway IDs) may add automatic admin notes on the membership when values change.
Return values
bool — true if the update succeeded, false if it failed (invalid membership ID or database error).
Examples
Extend expiration on membership #123:
$updated = rcp_update_membership( 123, array(
'expiration_date' => '2026-12-31 23:59:59',
) );
Update gateway IDs after a successful checkout:
rcp_update_membership( 123, array(
'gateway' => 'stripe',
'gateway_customer_id' => 'cus_abc123',
'gateway_subscription_id' => 'sub_xyz789',
'auto_renew' => true,
) );
Set status to active (for example after manual payment). For first-time activation with welcome email, use activate() on the membership object instead:
$membership = rcp_get_membership( 123 );
if ( $membership ) {
rcp_update_membership( 123, array(
'status' => 'active',
) );
}
To cancel with cancellation email and hooks, use $membership->cancel() rather than only setting status to cancelled.