Answer
The issue is in how the custom event checks group membership — fetching a single scalar value via a cursor and then comparing it against a string literal doesn't perform a genuine set-membership or per-site check. Replace that logic with a direct existence check instead: run a SELECT COUNT(*) against the multi-site-allowed configuration table, filtering specifically by both the current user AND the specific site/contract being transacted against, then block the transaction only when that count comes back as zero, rather than trying to fetch and compare a single row's value — this correctly validates the user's permission for that exact site rather than incorrectly evaluating group membership.