Restrict Content Pro
rcp_cancel_member_payment_profile()
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
Cancels the payment profile (subscription) at the gateway for the user’s primary membership (rcp_get_customer_single_membership()). Optionally sets membership status to cancelled (default true).
When multiple memberships are enabled, only that primary membership is cancelled—not every membership on the account.
Deprecated in 3.0. Use rcp_cancel_membership_payment_profile( $membership_id, $set_status ) when you have a membership ID. It returns true|WP_Error from the gateway layer. (There is no separate developer doc page for that function yet.)
Parameters
$member_id (int) – WordPress user ID. Default: 0 (current logged-in user, via rcp_get_customer_by_user_id()).
$set_status (bool) – Whether to set membership status to cancelled. Default: true.
Return values
(bool) – true if cancellation succeeded; false if there is no customer or membership, if $member_id is 0 and nobody is logged in, or if the gateway returned WP_Error.
Examples
$success = rcp_cancel_member_payment_profile( get_current_user_id() );
if ( $success ) {
// Payment profile cancelled at gateway.
}
$result = rcp_cancel_membership_payment_profile( $membership_id, true );
if ( is_wp_error( $result ) ) {
// Handle gateway error.
}
Related: Canceling Memberships, rcp_can_member_cancel(), rcp_get_membership_cancel_url().