Answers.Body: <p>This is currently expected behavior due to this bit of code, which explicitly passes in the primary site ID when generating those link URLs for a user:</p>
  
  <p><a href="https://github.com/craftcms/cms/blob/develop/src/services/Users.php#L1079-L1081" rel="nofollow noreferrer">https://github.com/craftcms/cms/blob/develop/src/services/Users.php#L1079-L1081</a></p>
  
  <p>The reasoning is that even on a multi-site setup, users are all "global" (i.e. not defined per site).</p>
  
  <p>If you feel this is a bug or produces undesired behavior, feel free to <a href="https://github.com/craftcms/cms/issues" rel="nofollow noreferrer">create an issue</a> where it can be further discussed.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-26T07:46:36.383Z
Answers.Text: done, here: https://github.com/craftcms/cms/issues/3029
Answers.UserDisplayName: monchito
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-25T23:48:22.470Z
Answers.LastActivityDate: 2018-06-25T23:48:22.470Z
Answers.UserDisplayName: Brad Bell
Body: <p>How can I change the domain in the generated <code>{{ link }}</code> in a system email, other than the primary domain?</p>
  
  <p>I have a multi domain setup in craft3, and it works fine everywhere, except ... for the system messages.</p>
  
  <p>For instance, when a user registers using a front-end entry form on a domain other than my primary domain, they receive the correct email, generated by the following template (Admin -> Email Settings -> System Messages):</p>
  
  <pre><code>Hey {{user.friendlyName}},
  
  Thanks for creating an account with {{siteName}}! To activate your account, click the following link:
  
  {{link}}
  
  If you were not expecting this email, just ignore it.
  </code></pre>
  
  <p><br>The <code>{{ siteName }}</code> is rendered correctly in the email, but the <code>{{ link }}</code> still points to the primary domain, something like this: <code>https://myprimaryandhtusthewrongdomain/actions/users/set-password?code=nicecode</code></p>
  
  <p>I use the mailgun adapter to send the mails btw</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-23T14:22:32.973Z
Comments.Text: Just some more background info. My setup is as follows: 1. on my server, three domains point to my /craft3/web/ folder as the document root. 2. I filled in the base url setting for all domains inside the control panel.  3. One of them is the primary domain. 4. It is however with domains other than the primary domain that system messages {{ link }} back to the primary domain, where they shouldn’t
Comments.UserDisplayName: monchito
Tags: <craft3><emails><multi-site>
Title: Multisite system messages: change domain in {{ link }}, other than primary domain
ThreadText: # Multisite system messages: change domain in {{ link }}, other than primary domain
  
  (Asked by: username_0 on 2018-06-19)
  
  How can I change the domain in the generated `{{ link }}` in a system email, other than the primary domain?
  
  I have a multi domain setup in craft3, and it works fine everywhere, except ... for the system messages.
  
  For instance, when a user registers using a front-end entry form on a domain other than my primary domain, they receive the correct email, generated by the following template (Admin -> Email Settings -> System Messages):
  
  ```
  Hey {{user.friendlyName}},
  
  Thanks for creating an account with {{siteName}}! To activate your account, click the following link:
  
  {{link}}
  
  If you were not expecting this email, just ignore it.
  
  ```
  
  The `{{ siteName }}` is rendered correctly in the email, but the `{{ link }}` still points to the primary domain, something like this: `https://myprimaryandhtusthewrongdomain/actions/users/set-password?code=nicecode`
  
  I use the mailgun adapter to send the mails btw
  
  **Tags:** craft3, emails, multi-site
  
  > **Comments:**
  > **username_0**: Just some more background info. My setup is as follows: 1. on my server, three domains point to my /craft3/web/ folder as the document root. 2. I filled in the base url setting for all domains inside the control panel.  3. One of them is the primary domain. 4. It is however with domains other than the primary domain that system messages {{ link }} back to the primary domain, where they shouldn’t  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-25. Score: 1
  
  This is currently expected behavior due to this bit of code, which explicitly passes in the primary site ID when generating those link URLs for a user:
  
  <https://github.com/craftcms/cms/blob/develop/src/services/Users.php#L1079-L1081>
  
  The reasoning is that even on a multi-site setup, users are all "global" (i.e. not defined per site).
  
  If you feel this is a bug or produces undesired behavior, feel free to [create an issue](https://github.com/craftcms/cms/issues) where it can be further discussed.
  
  > **Comments:**
  > **username_0**: done, here: https://github.com/craftcms/cms/issues/3029  
  
  ---
  
  