programatically filter users that join a room?

I need rooms where only users of certain entitlements can enter - I have member only rooms configured where I want to check the user's entitlement against our server to determine if they can join a member only room. What is the best way of doing this? modifying muc_room:get_affiliation to make a query against the server and return members affilation?
Any help would be greatly appreciated
Thanks
Beena

Syndicate content