How to store VM User First Name + VM User Last Name as Joomla Full Name?

Started by Genius WebDesign, April 15, 2014, 14:07:53 PM

Previous topic - Next topic

Genius WebDesign

Hi,

Im using VM v.2.0.26d
It seems that when a customer creates a new profile via the Virtuemart registration form, or when a new customer creates an order, then the userĀ“s email is stored as Joomla user "Full Name" field (not username).
Instead I would like it to store VM first name + last name as Joomla "Full Name".

How do I accomplish this?

Genius WebDesign

Has anyone had the same problem?

And does anyone know which file I should look into in order to change the VM registration to save the Joomla user info as explained?

Milbo

This is not done by vm. You can accomplish that with a js.
If input for displayed name is empty, fill it with vm firstname + lastname
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Genius WebDesign

Hi Milbo,

Thanks for the answer.
I found this script on the registration form page:

<script type="text/javascript">
document.getElementById("email_field").setAttribute("onchange", "mail_is_user()");

    function mail_is_user(){
var reg_email = document.getElementById("email_field").value
document.getElementById("name_field").value = (reg_email);
document.getElementById("username_field").value = (reg_email);
}
</script>


So I guess I could just modify this script to instead save the "name_field" as First Name + Last Name

Genius WebDesign

Furthermore, I found out that the code was located in one of the templateĀ“s override folders, so this problem is specific for my template only.

Genius WebDesign

Just to wrap it up, I finally got it working by changing the javascript to this:

<script type="text/javascript">
document.getElementById("email_field").setAttribute("onchange", "mail_is_user()");
    function mail_is_user(){
var reg_email = document.getElementById("email_field").value;
document.getElementById("username_field").value = (reg_email);
}

document.getElementById("first_name_field").setAttribute("onchange", "joomla_name_is_vmname()");
document.getElementById("last_name_field").setAttribute("onchange", "joomla_name_is_vmname()");
    function joomla_name_is_vmname(){
var first_name = document.getElementById("first_name_field").value;
var last_name = document.getElementById("last_name_field").value;
document.getElementById("name_field").value = (first_name + ' ' + last_name);
}
</script>

Milbo

Nice snippet. We could add it to the core layout. We could also do it in the model, but that would need an extra option. The js solution is easy to remove and to adjust.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Genius WebDesign

Yes, indeed.
It should be fairly easy to make some kind of VM admin implementation of this snippet.
Maybe the shopowner could then have some options to choose exactly how he want the registration form to save the VM user data in the core Joomla user tables.

Milbo

The problem is actually that the loginname is part of the password. It is a bit similar to the public key. So actually there should be at least a random alphanumeric in it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/