WooCommerce Membership Cancel in WordPress

A customer can usually cancel a membership in his dashboard. How can i restrict this (hide the cancel button) for a specific membership?

I found this code for general hide the cancel button, work’s so far:

function sv_edit_my_memberships_actions( $actions )
{   
    unset( $actions['cancel'] );
    return $actions}
add_filter( 'wc_memberships_my_account_my_memberships_actions', 'sv_edit_my_memberships_actions' );
}

maybe with this function?

wc_memberships_is_user_active_member( $current_user_id, 'membership-name' )

Read more here: WooCommerce Membership Cancel in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *