If I'm logged in as a user in user Group A, how can I tell which site I am currently viewing?

I want to be able to create a multilingual site switcher. But my setup is complex.

I have Company A, User A is in Group A

Company A Russian, User A is in Group A

Company A Hindi, User A is in Group A

I want to be able to let the user choose the Russian version of the current content. Same for Company B User B in Group B, etc. etc.

1 Answer 1


I built my site switcher like this:


You will have to define an array for your site variables in the general.php for each environment:

'siteUrl' => array(
  'default' => 'http://yoururl/',
  'english' => 'http://yoururl/en/',

You can also extend the user with a language field and let him save his preferred language with a simple form like the user profile form from the Craft 3 docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.