Add checkbox form fields that capture extended field info during signup with Login extra

Is it possible to use checkbox form fields that capture extended field information during signup with Login extra and if so what is the proper syntax for this?

I don’t understand what you are trying to do.
Can you explain in more detail what you want to happen during the Login process?

During the register/signup process I would like users to be able to fill out the signup form which includes a form field for ethnicity. The user should be able to select 1 or many ethnicities, if desired, using checkboxes. I would then like this value to be stored as an extended field within the user’s profile.

The Register snippet (from the Login extra) has a property &useExtended. If that is set to 1 (the default), then every parameter that is sent with the register form (and is not an existing field) should automatically be stored as an extended field in the user profile.

If that doesn’t work for you, then you could try writing a preHook that formats the submitted data (or possibly a postHook that stores the data).

Yes, I’m currently using other fields to capture various extended field values.These are all either simple input or select fields. My question, however, is how to use this for checkbox fields specifically.

FormIt, for example, has a way of handling this: FormIt.Handling Selects, Checkboxes and Radios - Tutorials and Examples | MODX Documentation

Is there a similar solution that can be done with the Register snippet?

I haven’t tested it, but it should work quite similar.
You should also be able to use the same output modifier “FormItIsChecked” from FormIt.


This seems to work and stores the fields like so:
Screen Shot 2023-09-11 at 12.22.15 PM

I’m currently using the Peoples extra in order to generate a CSV of users along with some information stored in the profiles, including extended field content. I was using the following code in the template chunk to display ethnicity when it was a select/dropdown field:


Now that it is a checkbox field, this placeholder is blank and does not display any information. I’m assuming because it now contains an array? Do you know how I can display the contents of this field accordingly?

I think with the Peoples extra, these values are only available in the chunk as the placeholders [[+extended.ethnicity.0]], [[+extended.ethnicity.1]] etc.

I would duplicate the Peoples snippet and adjust it to your needs.

Here in the snippet code

you could add more values to the $userArray.

Something like this may work: (untested!)

$ethnicities = $userArray['extended']['ethnicity'] ?? '';
if (is_array($ethnicities)){
    $userArray['ethnicities'] = implode(", ", $ethnicities); // becomes placeholder [[+ethnicities]] in chunk

Hi - I tried adding this code, but I’m getting a syntax error for the question marks “??”

Really? This operator should be available since PHP 7.0.
You could rewrite the line like this (but if you’re PHP version is older than 7, then please update it).

$ethnicities = isset($userArray['extended']['ethnicity']) ? $userArray['extended']['ethnicity'] : '';