Restrict Content Pro

rcp_add_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

Creates a new membership record in the database. Requires Restrict Content Pro 3.0 or later.

Use this for custom signup flows, imports, or admin automation. After creation, you may need to call RCP_Membership::activate() for active memberships so roles and welcome emails run as expected. To change an existing record, use rcp_update_membership() or methods on the RCP_Membership object.

Parameters

$data (array) — Membership data. Keys include:

Required

  • customer_id (int) — RCP_Customer ID this membership belongs to.

Commonly used

  • object_id (int) — Membership level ID. Must match a valid membership level; creation fails if the level cannot be loaded.
  • object_type (string) — Object type. Default membership.
  • status (string) — pending, active, cancelled, or expired. Default pending. (Legacy free is converted to active.)
  • signup_method (string) — live, manual, or imported. Default live.

Amounts and billing

  • currency (string) — Default is the site currency from rcp_get_currency().
  • initial_amount (string) — Initial charge. If omitted, RCP derives it from the membership level.
  • recurring_amount (string) — Renewal amount. If omitted, RCP derives it from the level.
  • auto_renew (bool) — Whether auto-renew is enabled. Default false.
  • times_billed (int) — Times billed so far. Default 0.
  • maximum_renewals (int) — Payment plan renewal cap (0 = unlimited). Default 0.

Dates

  • created_date (string) — MySQL datetime. Default current time.
  • trial_end_date (string) — Trial end; may be set automatically when the customer is trial-eligible and the level allows trials.
  • renewed_date (string) — Last renewal date.
  • cancellation_date (string) — Cancellation date.
  • expiration_date (string) — Expiration or next renewal. Leave empty to auto-calculate from the level (and upgrade context). Use none for no expiration (stored as lifetime / null).

Gateway

  • gateway (string) — Gateway slug.
  • gateway_customer_id (string) — Gateway customer ID (for example Stripe cus_…).
  • gateway_subscription_id (string) — Gateway subscription ID (for example Stripe sub_…).
  • subscription_key (string) — Unique key; generated if omitted when saved via membership methods.

Other

  • user_id (int|null) — WordPress user ID; backfilled from the customer when omitted.
  • upgraded_from (int) — Membership ID this one was upgraded from.
  • notes (string) — Notes on the membership. Prefer RCP_Membership::add_note() to append notes later.
  • disabled (int) — 0 enabled, 1 disabled (soft-deleted). Default 0.

Return values

int|false â€” New membership ID on success, or false on failure (missing customer_id, invalid level, or database error).

Examples

Create an active membership for customer #50 on level #2:

$membership_id = rcp_add_membership( array(
	'customer_id' => 50,
	'object_id'   => 2,
	'status'      => 'active',
) );

if ( $membership_id ) {
	$membership = rcp_get_membership( $membership_id );
	$membership->activate();
}

Manual admin grant with explicit expiration:

$membership_id = rcp_add_membership( array(
	'customer_id'     => 50,
	'object_id'       => 2,
	'status'          => 'active',
	'signup_method'   => 'manual',
	'expiration_date' => '2026-12-31 23:59:59',
) );
Last updated: October 7, 2026
Was this page helpful?
Thanks for the feedback!