Certain Landing pages for groups after login

Hi everyone,
I’m hosting a XWiki for two User Group. Every Group has it’s own area in the Xwiki. I managed that every group can only see their space.
Now the problem is that after every login every user gets directed to the Main.WebHome page.
I’d like to redirect them to the main page of their space when they log into the wiki.

I tried this velocity script on the Main Page:

#if($xwiki.getUser().isUserInGroup('XWiki.GroupIT'))
  {{display reference="IW.WebHome"/}}
#elseif($xwiki.getUser().isUserInGroup('XWiki.GroupFI'))
  {{display reference="FIW.WebHome"/}}
#else{{display reference="Main.WebHome"/}}
#end

For example, the URL for group IT ends with:
/xwiki/bin/view/IW/

As a test I only used
{{display reference=“IW.WebHome”/}}
in a velocity macro. And the right page was shown, but the differentiation betwen user groups is not working.

Is this not possible at all or am I simply doing it wrong?
I’d appreciate every kind of input.Thank you very much.

Yes it’s possible. You should probably use a redirect instead of the display macro, see https://snippets.xwiki.org/xwiki/bin/view/Extension/Redirect

It probably means you’re not using the right group page reference. For example for XWikiAdminGroup - XWiki on playground, the reference is in XWikiAdminGroup - XWiki and it’s XWiki.XWikiAdminGroup.

Based on your URLY you gave above, it seems your group page reference is IW.WebHome (which is slightly weird as group pages are usually located in the XWiki space).

Hi, this actually seems to work, but only when the cache is empty or a provate window is used. XWiki doesn’t open the main page after login but the page that was last opened in the session before.
So if I logout from Page XYZ then with a new login i get redirected to Page XYZ instead of the Main page.