Registration override with custom fields

27 views
Skip to first unread message

Michael Koontz

unread,
Feb 21, 2024, 12:47:22 PMFeb 21
to Joomla! General Development
I need some help with Custom Fields for users. FYI, the client's site is still using J3 (customized extensions require him to stay on it until he pays to have them J4/5 compatible).

Nevertheless, we need to add some custom fields to the "registration" page. However, he has a custom User Profile plugin that allows to collect First Name & Last Name instead of just one "Name" field.

As a result, an override was created to set the order the fields would display in for the Registration page so it would display the custom User Profile plugin above the default and the 'terms' at the end. The problem is, the override isn't working with Custom Fields so they don't show up on the frontend.

The code snippet for the override is this:

<?php $fieldsetsDefault = $this->form->getFieldsets(); ?>
<?php $fieldsetsOrdering = ['customprofile', 'default', 'terms']; ?>
<?php foreach ($fieldsetsOrdering as $fieldOrderingValue) : ?>
<?php $fieldset = $fieldsetsDefault[$fieldOrderingValue] ?? []; ?>
<?php if (empty($fieldset)) : ?>
<?php continue; ?>
<?php endif; ?>
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
<?php if (count($fields)) : ?>
<fieldset>
<?php echo $this->form->renderFieldset($fieldset->name); ?>
</fieldset>
<?php endif; ?>
<?php endforeach; ?>

You can see with the "fieldsetsOrdering" above that it sets the order of the fields. What I can't figure out is how to get it to display the custom fields after 'default' and before 'terms'.

I checked the default.php file, and the code snippet from that same section is this:

<?php // Iterate through the form fieldsets and display each one. ?>
<?php foreach ($this->form->getFieldsets() as $fieldset) : ?>
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
<?php if (count($fields)) : ?>
<fieldset>
<?php // If the fieldset has a label set, display it as the legend. ?>
<?php if (isset($fieldset->label)) : ?>
<legend><?php echo JText::_($fieldset->label); ?></legend>
<?php endif; ?>
<?php echo $this->form->renderFieldset($fieldset->name); ?>
</fieldset>
<?php endif; ?>
<?php endforeach; ?>

However, I can't find anything that specifically calls the custom fields and I haven't been able to find anything on how I can call the custom fields to have them display here in the override.

Do any of you have a suggestion on how I can get the custom fields to display with the override?

Thanks in advance for any help!
Reply all
Reply to author
Forward
0 new messages