Restrict Content Pro

rcp_get_membership_cancel_url()

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

Builds the nonce-protected URL a member uses to cancel a specific recurring membership (rcp-action=cancel and membership-id query args). RCP handles the request when the user visits that URL while logged in.

The URL is only generated when the membership is recurring; otherwise an empty string is returned. Filters: rcp_membership_cancel_url (since 3.0), rcp_member_cancel_url (deprecated).

Parameters

$membership_id (int) – Membership record ID.

Return values

(string) – Cancel URL, or empty string if the membership is not recurring.

Examples

$url = rcp_get_membership_cancel_url( $membership_id );

if ( $url && rcp_can_membership_be_cancelled( $membership_id ) ) {
	echo '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Cancel subscription', 'rcp' ) . '</a>';
}
Last updated: October 16, 2026
Was this page helpful?
Thanks for the feedback!