# Frontend login by name

**URL:** <https://forum.getkirby.com/t/frontend-login-by-name/19831>\
**Category:** Questions\
**Tags:** v3\
**Created:** [October 23, 2020, 7:31am UTC](https://forum.getkirby.com/t/frontend-login-by-name/19831 "2020-10-23T07:31:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saschabregenhorn](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/saschabregenhorn/32/7114_2.png) [@saschabregenhorn](https://forum.getkirby.com/u/saschabregenhorn)\
**Post date:** [October 23, 2020, 7:31am UTC](https://forum.getkirby.com/t/frontend-login-by-name/19831/1 "2020-10-23T07:31:42Z")

</div>

I’ve used the [access restriction recipe](https://getkirby.com/docs/cookbook/security/access-restriction) for a frontend login solution and it works fine.

Now I wonder if I could [fetch the user](https://getkirby.com/docs/cookbook/security/access-restriction#the-login-template) not by e-mail (username) but by the name, so I could use something like „Guest“ as a login name. I realize this could lead to problems since names are not unique, but I wonder if it’s possible.

I’ve unsuccessfully tried to change the controller to:

```
if ($user = $kirby->user()->username(get('loginname'))) {}

if ($user = $kirby->user('email@gmail.com')->username(get('loginname'))) {}

```

Thanks for help!

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [October 23, 2020, 7:43am UTC](https://forum.getkirby.com/t/frontend-login-by-name/19831/2 "2020-10-23T07:43:37Z")

</div>

> [@Login with name instead of email](https://forum.getkirby.com/t/login-with-name-instead-of-email/13019):
>
> Hi there, I’m trying to create a login page where users can log in with their name instead of email. How can I make this? This is the code I use to log in with email: // simple login form submission example if($username = get('username') and $password = get('password')) { $user = $kirby-\>user($username); if($user and $user-\>login($password)) { // redirect to the homepage // or any other page if(!cookie::exists('loggedin')) { cookie::set('loggedin', 'true'); } $url …

---

<div class="post-metadata">

**Author:** ![saschabregenhorn](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/saschabregenhorn/32/7114_2.png) [@saschabregenhorn](https://forum.getkirby.com/u/saschabregenhorn)\
**Post date:** [October 23, 2020, 7:46am UTC](https://forum.getkirby.com/t/frontend-login-by-name/19831/3 "2020-10-23T07:46:55Z")

</div>

Uh, didn’t find that, thanks!
