Author Topic: How to prevent editing custom user fields after registration?  (Read 226 times)

zuwann

  • Beginner
  • *
  • Posts: 1
  • A beginner
Hi,
I need to prevent editing some custom fields after registration from the buyer.
In details, in registration form i've added a user field that allows buyer to select the typology of customer (private or company). If the field is set read-only, in the registration form the buyer can select the value, but VM can not save it in user information. If the field is not read-only, the buyer can select the value during registration but at same time can change it in profile editing too. Well, I need this field can be selected during registration, but it must not be modified in profile.
At the moment I solved with a jQuery script, but I would like to solve this enigma with a more secure method.
How can i do this?

Thanks in advantage.

VirteMart 3.2.14, Joomla! 3.8.8

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3331
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to prevent editing custom user fields after registration?
« Reply #1 on: June 18, 2018, 10:11:58 am »
Have you try to disable the field in all form except in cart form ?
Another solution is to check if you are in cart on display user form in an override and hide the input in JOOMLAROOT\components\com_virtuemart\views\user\tmpl\edit_address_userfields.php
in the loop $field['name'] is the name of the field in the database.
Code: [Select]
<div style="display:none;"><?php $field['formcode'?></div>Is one way to hide it.
Another solution is to do own user field plugin(vmuserfield) so you can manage display, security .. with your own rules