Make first- and lastname required

Heya

Is there anyway to make the firstname and lastname a required field when creating a new user?

Thanks!

Hi,

You can create your own register form and make the firstname and lastname required.

thanks!
Any hint as to how I can do this? I couldn’t find any documentation - or I wasn’t looking right…?

You can start by searching on this page: https://getkirby.com/docs

To be more specific to your request, check this page: https://getkirby.com/docs/cookbook/creating-pages-from-frontend

https://getkirby.com/docs/panel/blueprints/form-fields#required-fields

and custom uset fields and defaults

https://getkirby.com/docs/panel/users#custom-user-form-fields

Well thats frontend, I don’t need (or want) to use a frontend form to add a new user.
It’s fine for me to do this in the panel

sorry, but this does not help at all.
Have you actually tried to understand what I was requesting?
As far as I know, there is no way to access the standard form field (eg /panel/users/add) via a blueprint.
You can extend it, but not alter it. And if you can, then please enlighten me, but your link does not help at all

No, there is no way to require these fields via a blueprint. Without modifying the source code, I’m afraid there is no way but to create users via the frontend.

1 Like

You could add a required option to these form fields in panel/app/forms/users/user.php.

  'firstName' => array(
      'label'     => 'users.form.firstname.label',
      'autofocus' => $mode == 'edit',
      'type'      => 'text',
      'width'     => '1/2',
      'required'  => true,
    ),

Unfortunately, this change alone does not throw an error message…

why is it not possible to override user default file completely? code seems like it could?

@bnomei: well, maybe it is possible.

Nope: https://getkirby.com/docs/panel/users#custom-user-form-fields
See the part Note: Custom user fields are only editable once a user has been created because you need to have the user object first.

I did a quick test and you definitely can’t overwrite the default fields, only add new fields.

I tried that, too, just to be sure before asking here :wink:

But ok, then I will have to live with the fact :slight_smile:

What you could do is remove those fields from the user.php mentioned above and re-add them via a user blueprint.

Good idea, but for one I don’t want to change anything in the core and secondly it will be an additional hassle to first have to create a user and then in the edit form to add more details.

If all else fails, I will have to do a frontend form and create the user from there.
According to the docs, it is possible to create the user and add additional fields in one go - which unfortunately is not possible as of now to do via the panel

Another option would be to replicate the user form in a custom Panel view that is accessible via a widget (and prevent access to the default user view using permissions), at least then your editors wouldn’t have to switch between front- and backend.

Example custom panel views:



thanks Sonja, I will look into it :slight_smile:

Vielen Dank für die schnelle Hilfe!