Hello,
i've read many Post about adding a user to a group programmatically. Unfortunately, none of them worked for me.
I can programmatically create users via UserManager.createUser(). After I successfully created a new User, I want to add him to a group 'users'.
The group already exists so I was trying to use following code:
public void addUserToGroup(User user) {
Group group = GroupManager.getInstance().getGroup("users");
JID jid = new JID(user.getUsername());
group.getMembers().add(jid);
}
I've found that code snippet in an answer on this site.
Then I've tried to use this example Java Code Example org.jivesoftware.openfire.group.Group (Example Number 9), even if I wouldn't understand how this event will add a new member to a group.
Like I said, none of them worked.
Can you please give information about "how can I add a group member to a group?"