Quantcast
Channel: Ignite Realtime : All Content - Openfire Dev
Viewing all articles
Browse latest Browse all 966

Add User to specific Group

$
0
0

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. Add User to group

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?"


Viewing all articles
Browse latest Browse all 966

Trending Articles