Restrict Content Pro
rcp_add_customer()
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 RCP customer record. Pass an existing WordPress user_id, or pass user_args so RCP can create the user with wp_insert_user(). Returns false if required user fields are missing, user creation fails, or a customer already exists for that user ID.
Parameters
$data (array) – All optional unless noted:
$user_id (int) – WordPress user ID for this customer. Use this orÂuser_args, not both paths without a user.$user_args (array) – Arguments forÂwp_insert_user() when creating a new account. Required keys whenÂuser_id is empty:Âuser_login,Âuser_email,Âuser_pass.$date_registered (string) – MySQL datetime. Default: current time.$email_verification (string) –Ânone,Âpending, orÂverified. Invalid values are ignored.$last_login (string) – MySQL datetime of last login.$ips (array) – Known IP addresses (stored serialized).$notes (string) – Admin notes.$has_trialed (int) – Whether the customer has trialed. Default:Â0.
Return values
(int|false) – New customer ID, or false on failure.
Examples
Link an existing user:
$customer_id = rcp_add_customer( array(
'user_id' => 42,
) );
Create user and customer together:
$customer_id = rcp_add_customer( array(
'user_args' => array(
'user_login' => 'jane_member',
'user_email' => '[email protected]',
'user_pass' => 'secure-password-here',
),
) );