Forums

Updating Profile Email Address

jhainsworth 03 Mar, 2012
I have a members form that has their email address in it.

Is there a way to update the Joomla profile email address when the user changes the email address in the member record?

Thanks
gabedaly 03 Mar, 2012
You can use a DB Save action that links to the Joomla! user table.
jhainsworth 03 Mar, 2012
OK, i can see how to reference the user_profiles table, but how do I tell the DB save which columns in the user_profile to updates and which field on the form the data is coming from, since there are lots of fields on the member form and in the user_profile table, but the only one that is common to both is the email address.
gabedaly 04 Mar, 2012
I'm not 100% positive but try testing this code in the advance section of the DB Record Loader action placed in the On Load event
<?php
$user = &JFactory::getUser();
echo "userid = ".$user->id
?>

This will pull up that users record and I don't know off the top of my head which column name is the primary key in the Joomla table but you will have to have that as one of your form inputs to be able to update the record (you can make it a hidden field).
Please test this first!!! I would assume it will update any column name in the Joomla profile that matches any of your forms input fields. So if you have "username" as a field in your form, then that will be updated too. You will need two DB Save actions if you want to update both Joomla profile and your member profile.
jhainsworth 10 Mar, 2012
Thanks, that put me on the right trail.

The trick is to have two db loads and two db saves with different data sets.

The info from my members table in one data set, which is displayed on the screen. The data from the joomla user table in the other data set, in hidden fields and updated through php with data from the screen fields.
gabedaly 10 Mar, 2012
Glad to hear you got it working.
This topic is locked and no more replies can be posted.