Show user based on subdomain Im using Domains Access to create a subdomain and already created all the virtualhosts, so that one is working.

Is it possible to show a user based on domain name?

Im creating a view, and i need to show for example:

lucas.site.com and show user lucas.

I have tried by adding contextual filter: User ID context on route.
But it doesn't take effect, it looks in lucas.site.com/lucas maybe im missing something?
Reply to my self:

I have created a custom Controller that get the user from db based on the domain, i get the subdomain using this:

$subdomain = substr_count($_SERVER['HTTP_HOST'], '.') &gt; 1 ? substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], '.')) : '';


Not sure if its the best.

Then i compare to the user on db:

$result = \Drupal::database()-&gt;select('user_data', 'n')
            -&gt;fields('n', array('id', 'user_domain', 'user_email'))
            -&gt;condition('n.user_domain', $subdomain)
            -&gt;execute()-&gt;fetchAllAssoc('id');


First you need to create a install schema with the domain created so you can fetch this.

Then loading by user email:

$user = user_load_by_mail($userEmail); 


and pass the variable to the Twig.
Not sure if its the best way.