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' )
You are almost there. You already have done some syntactical mistakes which @mujeeb specified. Try following code