The Login-Link in our Forum always use the XXX.myshopify.com internal Shop Domain instead our own Domain, even if we call the forum with our own domain. Probably you could use a script to use the domain, which the user is actually on and this would be solved in each case.