Update user_profile table with element value on form submission

Status
Not open for further replies.

Ghuerren

Member
Hi.
I have a list of clients. One of the elements is his telephone number:
clientes___celular

What i want to achieve is:

When the user update Fabriks form (click on Save button)
the element value (telephone number) is also updated on J! profile table

What i did:
1- selected the client for
2- added php plugin
3- set OnBeforeProcess
4- used the code

Code:
global $database;
$celular = mosGetParam($_POST, 'clientes___celular');
$uid = mosGetParam($_POST, 'chdg4_users___id');
$sql = "UPDATE chdg4_users_profile SET profile_value = celular WHERE profile_key = profile.phone AND user_id=$uid";
$database->setQuery($sql);
$database->query();

What happened: got error:

0
Call to undefined function mosGetParam()

CAn you guys help me with that, please?

Tx a lot!
 
Well, you must have found that code in a very old post or page, as moGetParam() and the global $database object haven't existed since J! 1.x.

Try ...

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$uid = $formModel->formData['chdg4_users___id'];
$uid = is_array($uid) ? $uid[0] : $uid;
$cellular = $formModel->formData['clientes___celular'];
$myQuery
   ->update('chdg4_users_profile')
   ->set('profile_value = ' . $myDb->quote($cellular))
   ->where('profile_key = profile.phone')
   ->where('user_id = ' . $myDb->quote($uid));
$myDb->setQuery($myQuery);
$myDb->execute();

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top