Add a Custom Field for Admin User

Do you need to save more information about your Admin Users? Lets see how you can add a custom field for an Admin User.

All our posts from now one will be based on Magento 2.3 version. In this post we are gonna a create a custom field for an Admin User so we can save the Admin User's telephone number.

Firstly we need to add a new field in the database table admin_user using a the following db_schema.xml.

After that we have to extend the Admin User form to add at the end an new input field for the telephone number. We override the Magento\User\Block\User\Edit\Tab\Main class using a preference like in the di.xml below.

In our overwritten class in the function _prepareForm after calling the parent _prepareForm function we add our telephone number input field.

So now the Admin User form will look like below.

The full example as extension can be found here.

Feel free to share this post and ask your questions in the comments below.

Till next time!