username cannot be entered at registration if set to 'read only'

Started by innato, October 01, 2016, 18:35:21 PM

Previous topic - Next topic

innato

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.
Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

innato

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.
Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/