How to add user custom fields to the edit profile form?

I had to add a series of custom fields to the joomla registration form. Thanks to the guide I managed to do it, both for the registration form and for the administrator form.

The process I followed for this are the following:

  1. Added the fields to the users table
  2. Added the fields in joomla user entity /library/src/user/user.php
  3. Added the fields and definition to /components/com_users/model/forms/registration.xml file to update the registration form
  4. Added the fields and definition to administrator/components/com_users/model/forms/user.xml file to update the user edition form for user with administrator role

Now I require the user to be able to change their profile data with the inthe fields that were created manually. To do this I added a link to the menu form to edit profile, here I expected to see all user fields, both native and custom created, but instead I obtain only the native fields, although upon inspecting the object (user) I can access all the user fields.

I created the fields by hand and then I expected that when they were saved they would persist, but it is not, when sending the form only the native data is updated and not the custom fields.

When I inspect, I see that a component named k2 is the one that facilitates this profile editing form, I am new to joomla and its ecosystem Could you please give me guidance on how to implement this task?

Greetings and thanks in advance

2 answers