This is explained in the paragraph:
If the room is members-only, the service MAY also add the invitee to the
member list. (Note: Invitation privileges in members-only rooms SHOULD be
restricted to room admins; if a member without privileges to edit the
member list attempts to invite another user, the service SHOULD return
a <forbidden/> error to the occupant; for details, see the Modifying the
Member List section of this document.)
https://xmpp.org/extensions/xep-0045.html#invite-mediated
ok | {error, stanza_error()}.
check_invitation(From, Invitations, Lang, StateData) ->
FAffiliation = get_affiliation(From, StateData),
- CanInvite = (StateData#state.config)#config.allow_user_invites orelse
+ CanInvite = ((StateData#state.config)#config.allow_user_invites
+ and not (StateData#state.config)#config.members_only) orelse
FAffiliation == admin orelse FAffiliation == owner,
case CanInvite of
true ->