Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:

Filters whether or not a gateway subscription has been successfully canceled. Third-party gateways should use this to process cancellations and return true if the cancellation was successful, or WP_Error if not.


  • $success (true|WP_Error) - True if the cancellation was successful, WP_Error object if not.
  • $gateway (string) - Gateway slug. Make sure to only process cancellations if this value matches your gateway slug.
  • $gateway_subscription_id (string) - Gateway subscription ID. This is the subscription to cancel in the gateway.
  • $membership_id (int) - ID of the membership being canceled.
  • $membership (RCP_Membership) - Membership object.


function rcp_elements_cancel( $success, $gateway, $gateway_subscription_id, $membership_id, $membership ) {
	// If it was already cancelled or not Stripe Elements gateway, bail.
	if ( $success || $gateway !== 'stripe_elements' ) {
		return $success;

	return rcp_stripe_cancel_membership( $gateway_subscription_id );
add_filter( 'rcp_membership_payment_profile_cancelled', 'rcp_elements_cancel', 10, 5 );
Have more questions? Submit a request
Powered by Zendesk