Forums

Where in my forms settings should I be putting this?

innovate.invent 07 Jul, 2010
Hey all, I hope I don't catch too much flame for asking this but I have been poking around the forums and can't seem to find a definite answer to this one...

I have a form that loads up the users name and email address and allows them to change it.
So I figured to update the JUser object all I had to do was put this code:

<?php
$user = JFactory::getUser();
$user->name = JRequest::getVar('name');
$user->email = JRequest::getVar('email');
$user->save(true);
?>

in the "On Submit code - before sending email" field but I guess I don't understand how that field is used..

Could anyone point out my mistake?
GreyHead 07 Jul, 2010
Hi innovate.invent,

That code looks good to me. I woudl make one change to add =& here to make doubly sure that you are editing the User Object in use and not a copy of it.
$user =& JFactory::getUser();


Note that the OnSubmit Before Email box code is only executed if "Send Emails" is set to 'Yes' on the form General tab.

Bob
innovate.invent 07 Jul, 2010
Ah, I see. I do not wish to send an email for this form. Where should that code be placed otherwise?
GreyHead 07 Jul, 2010
Hi innovate.invent,

Just set 'Send Emails' to 'Yes' - it doesn't mean tha tyou have to actually send any.

Bob
This topic is locked and no more replies can be posted.