Correct way of using 'First name / Last Name' instead of Fullname

In a standard, classic Plone 6.0.5b site:

  1. What is the 'correct' way of ' using First and Last name instead of Full Name.
  2. Which schema needs to be modified to move First Name / Last Name to top of 'add user schema / template ' etc

I am also interested in this topic, and any assistance would be greatly appreciated.

Does this help? Schemas — Plone Documentation v6

I have not figured it out yet, but this did not work:

 <field name="first_name" type="zope.schema.TextLine" users:forms="In User Profile"  form:before="last_name">
    <description/>
    <title>First Name</title>
  </field>

I did try again now, and it looks like something like this might work:
Please note: I am not sure if this is the best/correct way:

  <browser:page
      name="personal-information"
      for="plone.app.layout.navigation.interfaces.INavigationRoot"
      class=".userdatapanel.CustomUserDataPanel"
      permission="cmf.SetOwnProperties"
      layer="my.addon.interfaces.IMyLayer"
      />


from AccessControl.SecurityManagement import getSecurityManager
from plone.app.users.browser.account import getSchema
from plone.app.users.schema import IUserDataSchema
from plone.base import PloneMessageFactory as _ 
from Products.CMFPlone.utils import get_portal  
from plone.app.users.browser.userdatapanel  import UserDataPanel, UserDataPanelAdapter


class CustomUserDataPanel(UserDataPanel):

    def updateFields(self):
        super().updateFields()
        # Get the existing field names in their current order
        existing_field_names = list(self.fields.keys())

        # Move 'last_name/first_name' to the front, keeping all other fields in their original order
        reordered_fields = ['last_name', 'first_name'] + [name for name in existing_field_names if name not in ['first_name', 'last_name']]

        # Rebuild the fields object in the desired order
        self.fields = self.fields.select(*reordered_fields)
    
def getUserDataSchema():
    portal = get_portal()
    form_name = "In User Profile"
    if getSecurityManager().checkPermission("Manage portal", portal):
        form_name = None
    schema = getSchema(IUserDataSchema, UserDataPanelAdapter, form_name=form_name)
    
    
    return schema

I have seen this, but it’s still not clear.
For instance, I need to modify the registration form to make the fullname field mandatory. This problem is very similar to the original question about replacing fullname with first and last name fields.
As far as I understand, I need to create a custom schema interface to extend the registration form schema and then register it in configure.zcml.
To do this, I create my interface in interfaces.py:

from zope.interface import Interface

class IMyUserDataSchema(Interface):
    fullname = schema.TextLine(
        title=_(u'label_full_name', default=u'Full name'),
        description=_(u'help_firstname', default=u"Fill in your full name."),
        required=True,
        )

with new fullname and all the other fields for the registration form.

First of all, is it correct to I inherit this class from zope.interface.Interface?

Then, how do I register it in configure.zcml? After exploring the documentation, I came up with the code below, but it does not work - the registration form remains unchanged.

  <browser:page
      name="register"
      for="plone.app.layout.navigation.interfaces.INavigationRoot"
      layer=".interfaces.IMyUserDataSchema"
      />

Not on computer, but I would consider making fullname with a default value and hidden. Then a subscriber that sets the fullname after save.

If you need another field you could add that in an xml file in profiles or in the control panel

Of course, one can do this, but it doesn't seem elegant to me at all. I'd like to understand what makes the fullname field special such that it cannot be modified using userschema.xml .

If I remember right, it (and email) is defined as a 'protected field', so I am almost sure you have to 'keep them'.

From the docs:

The entire schema can be freely modified, but:

 the Fullname and the Email fields cannot be removed nor changed,
we can only add one Image field (that will be used as the user portrait), and no more.

Right, this is mentioned in the plone.app.users README, but it's nuclear to me whether this limitation applies only to userschema.xml or also to schema definition in Python?

So you've to override it implementing a method protected which returns false.

fullname is a ProtectedTextLine:

Said that, I don't understand what is the use case to declare a field "protected"...

this is the commit