Make first- and lastname required


#1

Heya

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

Thanks!


#2

Hi,

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


#3

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


#4

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


#5

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


#6

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


#7

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


#8

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.


#9

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…


#10

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


#11

@bnomei: well, maybe it is possible.


#12

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.


#13

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


#14

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:


#15

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


#16

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


#17

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:




#18

thanks Sonja, I will look into it :slight_smile:

Vielen Dank fĂĽr die schnelle Hilfe!