Index: ejabberd-trunk-quilt/src/mod_shared_roster.erl
===================================================================
--- ejabberd-trunk-quilt.orig/src/mod_shared_roster.erl
+++ ejabberd-trunk-quilt/src/mod_shared_roster.erl
@@ -19,6 +19,7 @@
 	 process_item/2,
 	 in_subscription/6,
 	 out_subscription/4,
+	 user_registered/2,
 	 list_groups/1,
 	 create_group/2,
 	 create_group/3,
@@ -63,7 +64,9 @@ start(Host, _Opts) ->
     ejabberd_hooks:add(roster_get_jid_info, Host,
         	       ?MODULE, get_jid_info, 70),
     ejabberd_hooks:add(roster_process_item, Host,
-        	       ?MODULE, process_item, 50).
+        	       ?MODULE, process_item, 50),
+    ejabberd_hooks:add(user_registered, Host,
+         	       ?MODULE, user_registered, 50).
 %%ejabberd_hooks:add(remove_user, Host,
 %%    	       ?MODULE, remove_user, 50),
 
@@ -83,7 +86,9 @@ stop(Host) ->
     ejabberd_hooks:delete(roster_get_jid_info, Host,
         		  ?MODULE, get_jid_info, 70),
     ejabberd_hooks:delete(roster_process_item, Host,
-			  ?MODULE, process_item, 50).
+			  ?MODULE, process_item, 50),
+    ejabberd_hooks:delete(user_registered, Host,
+			  ?MODULE, user_registered, 50).
 %%ejabberd_hooks:delete(remove_user, Host,
 %%    		  ?MODULE, remove_user, 50),
 
@@ -364,6 +369,89 @@ remove_user_from_group(Host, US, Group) 
 	end,
     mnesia:transaction(F).
 
+user_registered(User, Server) ->
+    LUser = jlib:nodeprep(User),
+    LServer = jlib:nameprep(Server),
+    US = {LUser, LServer},
+    DisplayedGroups = get_user_displayed_groups(US),
+    lists:foreach(
+      fun(Group) ->
+	      USs = get_group_users(LServer, Group),
+	      lists:foreach(
+		fun({U, S} = US1) ->
+			Item = #roster{usj = {U, S, {LUser, LServer, ""}},
+				       us = US1,
+				       jid = {LUser, LServer, ""},
+				       name = "",
+				       subscription = both,
+				       ask = none,
+				       groups = [get_group_name(
+						   LServer, Group)]},
+			push_item(U, S, jlib:make_jid("", S, ""), Item)
+		end, USs)
+      end, DisplayedGroups).
+
+
+push_item(User, Server, From, Item) ->
+    ejabberd_sm:route(jlib:make_jid("", "", ""),
+		      jlib:make_jid(User, Server, ""),
+		      {xmlelement, "broadcast", [],
+		       [{item,
+			 Item#roster.jid,
+			 Item#roster.subscription}]}),
+    lists:foreach(fun(Resource) ->
+			  push_item(User, Server, Resource, From, Item)
+		  end, ejabberd_sm:get_user_resources(User, Server)).
+
+push_item(User, Server, Resource, _From, Item) ->
+    ResIQ = #iq{type = set, xmlns = ?NS_ROSTER,
+		id = "push",
+		sub_el = [{xmlelement, "query",
+			   [{"xmlns", ?NS_ROSTER}],
+			   [item_to_xml(Item)]}]},
+    ejabberd_router:route(
+      jlib:make_jid(User, Server, Resource),
+      jlib:make_jid(User, Server, Resource),
+      jlib:iq_to_xml(ResIQ)).
+
+item_to_xml(Item) ->
+    Attrs1 = [{"jid", jlib:jid_to_string(Item#roster.jid)}],
+    Attrs2 = case Item#roster.name of
+		 "" ->
+		     Attrs1;
+		 Name ->
+		     [{"name", Name} | Attrs1]
+	     end,
+    Attrs3 = case Item#roster.subscription of
+		 none ->
+		     [{"subscription", "none"} | Attrs2];
+		 from ->
+		     [{"subscription", "from"} | Attrs2];
+		 to ->
+		     [{"subscription", "to"} | Attrs2];
+		 both ->
+		     [{"subscription", "both"} | Attrs2];
+		 remove ->
+		     [{"subscription", "remove"} | Attrs2]
+	     end,
+    Attrs4 = case ask_to_pending(Item#roster.ask) of
+		 out ->
+		     [{"ask", "subscribe"} | Attrs3];
+		 both ->
+		     [{"ask", "subscribe"} | Attrs3];
+		 _ ->
+		     Attrs3
+	     end,
+    SubEls1 = lists:map(fun(G) ->
+				{xmlelement, "group", [], [{xmlcdata, G}]}
+			end, Item#roster.groups),
+    SubEls = SubEls1 ++ Item#roster.xs,
+    {xmlelement, "item", Attrs4, SubEls}.
+
+ask_to_pending(subscribe) -> out;
+ask_to_pending(unsubscribe) -> none;
+ask_to_pending(Ask) -> Ask.
+
 
 %%---------------------
 %% Web Admin
Index: ejabberd-trunk-quilt/src/mod_register.erl
===================================================================
--- ejabberd-trunk-quilt.orig/src/mod_register.erl
+++ ejabberd-trunk-quilt/src/mod_register.erl
@@ -174,6 +174,8 @@ try_register(User, Server, Password) ->
 		allow ->
 		    case ejabberd_auth:try_register(User, Server, Password) of
 			{atomic, ok} ->
+			    ejabberd_hooks:run(user_registered, Server,
+					       [User, Server]),
 			    send_welcome_message(JID),
 			    send_registration_notifications(JID),
 			    ok;
