Adding users by modifying plugin userservice

Have been playing with PHP to add users to Wildfire, that works just fine. However, I was unable to allow them to use the conference room (groupchat) without restarting wildfire.

Looking through the plugins I found UserService. Now let’'s assume I would add the following to it:

import org.xmpp.muc.JoinRoom

and add

joinRoom = new JoinRoom(email, name_of_room/username);



public void createUser(String username, String password, String name, String email)

throws UserAlreadyExistsException


userManager.createUser(username, password, name, email);

putting it somewhere here.


Would that work, or should I feed it name_of_room/username as one string?

But also, if I would feed users via something like this, would Wildfire allow them to join the room immediately or would I still have to restart Wildfire? Access is limited to users who have been granted access.

Before I try to figure out how to compile it I would appriciate a word of advice… Being new to java doesn’'t make it easier

If there was a simple method to get wildfire to refresh it’'s data conference room users from the database then that would be a lot easier to use…


I had a quick look at this and I am not sure it would work as you have written it. In essence I think the trick is probably to use the MUCRoom object to add your users. Though I am not familiar with

conference rooms actually, but this did work …(chatroom = theroom, admin member = theroomadmin)

You will need to declare at the top of the class:

private MultiUserChatServer multiUserChatServer;

and in initialize plugin:

multiUserChatServer = server.getMultiUserChatServer

then edit createUser method:

public void createUser(String username, String password, String name, String email) throws UserAlreadyExistsException{

userManager.createUser(username, password, name, email);

MUCRoom theroom = multiUserChatServer.getChatRoom(“theroom”);


MUCRole adminRole = theroom.getOccupant(“theroomadmin”);


}catch(Exception e){



The problem is that getOccupant requires the admin member to be logged on and in the room. I am sure with some fishing around in the API for MUCRoom you can find another way to get a hold of a role that will allow you to add users.

Must be info on building Wildfire plugins in the docs on this site. I edit in eclipse, but you can just use ant to build it, and edit the UserServicePlugin file using a text editor, since the changes are minimal.

Good luck

Justin Hunt


Thank you for your reply.

I tried what you suggested but it didn’'t work.

Looked at the muc-room-affiliations.jsp file and got a few parts that did get me a bit futher. Been working on this for >6 hours with no idea when it will be solved.

I hope that someone who has a fix is willing to share it.

Maybe this will work:

public void createUser(String username, String password, String name, String email) throws UserAlreadyExistsException{

userManager.createUser(username, password, name, email);

/* This will create muc user */

MUCUser mucUser = mucUserChatServer.getChatUser (“your_user_JID”);

/* This will create the room */

MUCRoom room = multiUserChatServer.getChatRoom(“roomName”);

Presense presense = new Presence();

/* Fill in users’‘s muc presence here that include the above info. It’'s needed in joinRoom */

/* joinRoom (String, String, HistoryRequest, MUCUser, Presence) */

MUCRole role = room.joinRoom(“your_user_nick”, null, null, mucUser, presence.createCopy());



Also don’‘t forget to import org.jivesoftware.wildfire.muc.spi and everything that’'s required.

The above is just what I think the codes should be, but I haven’‘t tried it myself. You’‘ll probably need to tweak here and there, plus error checking. I’'m interested to know if your final codes work.

I may have misunderstood exactly the result you are looking for, but the code that I posted does work. It adds the member under creation to a preexisting chat room called “theroom.” The chat room is members-only. You will need to create this room manually before anything will work.

In any event I reworked it so that it uses the role of the chatroom itself to add the user as a member to a multi user chat room, and it all works nicely. There is no need for a phantom theroomadmin user or anything like that.

Really the changes that I have posted are proof of concept only, to extend the user service plugin properly you should add separate http accessible calls for manipulating chat rooms. (Not to mention the fact that the chatroom is name is hardcoded!) It is quite simple, and I can do this and other changes you suggest, but I am very busy and have difficulty finding time to get it done. If you are in a hurry you would indeed be better getting stuck into it yourself, or sending me a private message;)

The src code is at:

The precompiled plugin is at:

good luck

Message was edited by: justinhunt

Message was edited by: justinhunt

Hi Justin,

Thanks much for helping me out like this! I really appreciate it.

I downloaded the modified version (source) you created. If you use that version it will indeed add a user to a room but that new user can’'t enter it.

Somewhere around line 83 it reads:


But that needs to be:


And then it works just fine.

I’'m aware of the fact that it will only allow to add to one fixed room only. But if you would need it to support mutiple rooms it should be able to pass a roomname and use that value… correct?

Glad to be able to help.

Yes you are right, as I wrote you were unable to actually enter theroom. Ooops sorry about that. You don’'t seem to be doing to bad for a java newbie.

To do it properly you will want to add a method to UserServicePlugin that adds a user to a room, say “joinRoom(String email, String name, String roomName).” Then put the code for joining a room in there.

Then change UserServiceServlet doGet method to look for a new type “joinRoom” in the http request. You will also need to add processing code for a “roomName” paramater here, and add the paramater to your actual http request. Once you have all the info from the http request and the “type” parameter comes through as “joinRoom” the servlet should then call the UserServicePlugin’'s joinRoom method.

Then from the php side, after you create each user, you send a separate http request to the userservice plugin to join that user to the conference room.

Good luck, and please let me know how you get on.

Justin Hunt