Skip to content

User sections (PRO)

Custom fields on the MODX user form: a phone number, a company, a business role, anything the standard profile does not have.

The mechanism is the same as for resource fields — a section with fields in it — with the context set to the user.

A section

SettingWhat it does
NameThe caption of the tab or panel
ContextpbUser — this section belongs to the user form
Placementtab, panel or default
DescriptionText above the fields
PositionOrder among the sections
PermissionsWhich users and groups see it
PublishedAn unpublished section is not rendered

Where the values live

In modx_user_attributes.extended — the profile's JSON column, the same place MODX itself uses for extended profile data.

Read user fields through the profile, not the user

In MODX the user row holds little more than the username. email, fullname and every custom field live in the profile:

php
$user->email;              // empty
$user->profile->email;     // the value

This catches everyone once. A user list that renders blank cells is almost always this and not a missing value.

Saving happens after the core, deliberately

The fields are written on OnUserSaveafter the MODX processor has run.

The order is not incidental. The processor rewrites extended wholesale from what the form sent it; writing first would mean writing into something the core then overwrites. Running afterwards is the only point at which the value survives.

Do not "optimise" this to an earlier event

OnBeforeUserFormSave looks like the natural place and silently loses every custom field. If you add your own handler for user data, hook the same event and for the same reason.

Fields on the front end

A profile form on the site is an ordinary controller and form: validate, then write through the profile. The section on the manager form and a form on the site are two views of the same storage — there is no separate front-end field mechanism to learn.

© PageBlocks 2019-present