rcp_get_membership_cancel_url()

Returns the membership cancellation URL for a given membership. It's a good idea to pair this with  RCP_Membership-can_cancel().

Parameters:

  • $membership_id - ID of the membership.

Return values:

  • (string) Cancellation URL. An empty string may be returned if the user does not have a recurring membership.

Example usage:

$membership = rcp_get_membership( 1 );
if ( $membership->can_cancel() ) {
    printf( __( '<a href="%s">Click here to cancel your membership</a>', 'rcp' ), esc_url( rcp_get_membership_cancel_url( $membership->get_id() ) ) );
}