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_type
  • currency, initial_amount, recurring_amount
  • created_date, trial_end_date, renewed_date, cancellation_date, expiration_date
  • auto_renew, times_billed, maximum_renewals, status
  • gateway, gateway_customer_id, gateway_subscription_id
  • signup_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.

Last updated: October 7, 2026
Was this page helpful?
Thanks for the feedback!