VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: innato on October 01, 2016, 18:35:21 PM

Title: username cannot be entered at registration if set to 'read only'
Post by: innato on October 01, 2016, 18:35:21 PM
VM3.0.18 on J3.6.2 and PHP5.6.24

I don't want registered users to change their username once they have registered. This is for tracking reasons.
The solution is probably to set Shopper Field username 'Read-Only' radio button to 'yes' in VM configuration. But then, new registrations through VM cannot fill in a username because the empty form field is made 'read only' and cannot be changed.

The same probably applies to all other fields as well. I haven't checked this.
Title: Re: username cannot be entered at registration if set to 'read only'
Post by: GJC Web Design on October 01, 2016, 18:47:44 PM
this?

Title: Re: username cannot be entered at registration if set to 'read only'
Post by: innato on October 01, 2016, 20:12:08 PM
Quote from: GJC Web Design on October 01, 2016, 18:47:44 PM
this?
No, this affects the Joomla-based function ("User profile") only and not the VM account maintenance ("Shopper Information") routines.
My solution/work-around is to exempt the readonly attribute when the field is empty.
As presented below (base is VM3.0.18).

File /administrator/components/com_virtuemart/models/userfields.php

Lines 802 to 807 reads:
$readonly = '';
if(!$admin){
if($_fld->readonly ){
$readonly = ' readonly="readonly" ';
}
}


Change the second if condition into:
$readonly = '';
if(!$admin){
if( $_fld->readonly && !empty($_userData[$_fld->name]) ){
$readonly = ' readonly="readonly" ';
}
}


Fixed!! But... a core hack, something I don't really want to do.
Title: Re: username cannot be entered at registration if set to 'read only'
Post by: Milbo on October 04, 2016, 10:34:26 AM
Nice idea, but why do you not use the correct fix. The correct fix is to implement the joomla setting to our usermodel, so that users cannot change their name.