Fixed Serious bug with custom user fields

HWS

Well-known member
We use a custom user field, require it at registration, but do not want users to change it afterwards via account settings. As per your instructions, we set up a custom user field and mark it "Editable only once" under "General Options".

Now, if a user registers and sends the register form with errors, the register screen shows again, this time with an error message where the details of the error are specified.

BUT, and this is a major bug, all custom user fields specified with "Editable only once" (even IF required and sent empty or with a wrong value/error message the first time) do NOT show up again!

So a new user CAN successfully register without the required custom user field.

Please specify a bug fix to solve this, we need to patch our installation urgently.

Thank you.
 
Confirmed in 1.1.2.

To reproduce I created two required "editable once" fields. I visited the registration form and filled in only one of the required fields. Upon submit it gives an error on the empty field and displays it again. But the required field that I filled in is now missing from the registration form. The software takes the entered value as having satisfied the "editable once" field even though it wasn't saved.
 
It's a unique situation with the registration form because it reloads the form on submit errors. This doesn't happen anywhere else.

One fix would be to modify the templates:

Admin CP -> Appearance -> Templates -> register_form

Replace this:

Code:
	<xen:include template="custom_fields_edit" />

With this:

Code:
	<xen:include template="custom_fields_edit">
		<xen:set var="$registration">1</xen:set>
	</xen:include>

Admin CP -> Appearance -> Templates -> custom_fields_edit

Add the red code:

Rich (BB code):
<xen:foreach loop="$customFields" value="$field">
	<xen:if is="{$field.isEditable} OR ({$registration} AND {$field.user_editable} == 'once')">
		<xen:include template="custom_field_edit" />
	</xen:if>
</xen:foreach>

Or another solution would be to implement this check in the controller and model. Add a flag to these functions:

XenForo_Model_UserField::prepareUserFields
XenForo_Model_UserField::prepareUserField

And then set that flag in the controller:

XenForo_ControllerPublic_Register::_getRegisterFormResponse
 
It has been released with 1.1.3
Otherwise you can use the fixes posted above by Jake. Both of them solve this issue.
 
Top Bottom