<p>You can either use the same form or two different forms with separate URLs. Craft doesn't really care where your login form submission comes from, it's handed off to the same controller regardless. Which approach is better depends on how much your forms differ and how you prefer to write your templates. For the single-form approach, you can use a URL parameter to check the form 'type' and modify the template based on that (as in your example). Or use two completely separate forms with their own templates.</p>
<p>The only thing Craft 'knows' about your login URL is the <a href="https://craftcms.com/docs/3.x/config/config-settings.html#loginpath" rel="nofollow noreferrer"><code>loginPath</code> config setting</a>. But you're not limited to that, you can point any path to your login form template(s) using <a href="https://craftcms.com/docs/3.x/routing.html" rel="nofollow noreferrer">custom routes</a>, so you can pretty much do whatever you want in terms of offering different login forms.</p>
<p>One thing that might trip you up is that Craft's controllers use the <code>loginPath</code> setting to determine where to redirect users that are trying to perform an action that requires login, as well as the redirect for the <a href="https://craftcms.com/docs/3.x/dev/tags.html#requirelogin" rel="nofollow noreferrer"><code>{% requireLogin %}</code> tag</a>. Two possible solutions to that:</p>
<ul>
<li>Instead of hard-coding the value, you can set the <code>loginPath</code> to a callback that returns the login path based on the current session / request. You can use this to dynamically change which login form users get redirected to for certain actions / in certain situations.</li>
<li>You could also just not use the <code>{% requirePermission %}</code> tag and make sure that in your 'normal' user flow the user logs in before trying to execute an action that will redirect to the login page automatically.</li>
<li>In both login forms, add links to switch between the two different forms so users can find the correct form for them if they end up on the wrong one.</li>
</ul>

CC BY-SA 4.0
2021-09-15T08:33:59.387Z
Thank you for your feedback. Wasn't clear you could use different login forms because of the (limitations of) loginPath settings.
Robbie Post
CC BY-SA 4.0
2021-09-14T14:38:30.697Z
2021-09-14T14:38:30.697Z
MoritzLost
<p>I have a need for 2 different login forms: customers and professionals. Each login form is slightly different in markup and heading and has different linkages to the registrations form(s) if a visitor (customer or pro) has not been registered yet.</p>
<p>What I've seen so-far is that only one form can be used: /login.</p>
<p>A solution might be to add a query string to the login link, like /login?pro and then based on the query string filter the right form content.</p>
<pre><code>{% if craft.app.request.queryString('login') == 'pro' %} do something {% endif %}
</code></pre>
<p>Any thoughts or suggestions would be welcome?</p>

CC BY-SA 4.0
2021-09-14T14:42:06.747Z
Is there anything in particular that's not working for you? If the only problem is how to route different login URLs to the same template, you can use custom routes for that, see my answer below.
MoritzLost
<craft3><form><login>
Multiple login forms
# Multiple login forms

(Asked by: username_0 on 2021-09-14)

I have a need for 2 different login forms: customers and professionals. Each login form is slightly different in markup and heading and has different linkages to the registrations form(s) if a visitor (customer or pro) has not been registered yet.
What I've seen so-far is that only one form can be used: /login.
A solution might be to add a query string to the login link, like /login?pro and then based on the query string filter the right form content.
{% if craft.app.request.queryString('login') == 'pro' %} do something {% endif %}

Any thoughts or suggestions would be welcome?

**Tags:** craft3, form, login
> **Comments:**
> **username_1**: Is there anything in particular that's not working for you? If the only problem is how to route different login URLs to the same template, you can use custom routes for that, see my answer below.  

---

## 1 answers

### Answer by username_1 on 2021-09-14. Score: 1 | Accepted answer

You can either use the same form or two different forms with separate URLs. Craft doesn't really care where your login form submission comes from, it's handed off to the same controller regardless. Which approach is better depends on how much your forms differ and how you prefer to write your templates. For the single-form approach, you can use a URL parameter to check the form 'type' and modify the template based on that (as in your example). Or use two completely separate forms with their own templates.

The only thing Craft 'knows' about your login URL is the [`loginPath` config setting](https://craftcms.com/docs/3.x/config/config-settings.html#loginpath). But you're not limited to that, you can point any path to your login form template(s) using [custom routes](https://craftcms.com/docs/3.x/routing.html), so you can pretty much do whatever you want in terms of offering different login forms.

One thing that might trip you up is that Craft's controllers use the `loginPath` setting to determine where to redirect users that are trying to perform an action that requires login, as well as the redirect for the [`{% requireLogin %}` tag](https://craftcms.com/docs/3.x/dev/tags.html#requirelogin). Two possible solutions to that:

* Instead of hard-coding the value, you can set the `loginPath` to a callback that returns the login path based on the current session / request. You can use this to dynamically change which login form users get redirected to for certain actions / in certain situations.
* You could also just not use the `{% requirePermission %}` tag and make sure that in your 'normal' user flow the user logs in before trying to execute an action that will redirect to the login page automatically.
* In both login forms, add links to switch between the two different forms so users can find the correct form for them if they end up on the wrong one.

> **Comments:**
> **username_0**: Thank you for your feedback. Wasn't clear you could use different login forms because of the (limitations of) loginPath settings.  

---

