Forums

Send results to logged in user?

Bullfn33 12 Jul, 2008
How can you send the form results to the logged-in user's email address?
GreyHead 12 Jul, 2008
Hi bullfn33,

You can access all of the logged in users info using the $my Object. The code is slightly different in the Joomla versions. In either case create a dummy field in your form:
<input type="hidden" name="user_email" value="" />
Then, in the Onsubmit before box, for 1.0.x use:
<?php
global $my;
$_POST['user_email'] = $my->email;
?>
or for Joomla 1.5.x use:
<?php
$user = & JFactory::getUser();
$_POST['user_email'] = $user->email;
?>
Then you can use the {user_email} field as you would any other.

Bob

PS From memory, not tested, may be buggy!
Bullfn33 12 Jul, 2008
OK, I got it to send the results to the user's email. However, I had previously had the Profile Page plugin set up to pull the username from another hidden field and include it in the saved data but now it is not saving the username there.

Is adding in the code to pull the user's email somehow interfering with the Profile Page plugin set up for the username pull? Thanks
GreyHead 18 Jul, 2008
Hi Bullfn33,

I don't have the slightest idea - I'm not even sure that I understand the question fully. Can you post the Form backup and instructions on how to set it up with the plugin so that i can try it out.

Why are you using the plugin to pull the username - that's available from the $my or $user Object?

Bob
Bullfn33 19 Jul, 2008
Never mind, I got it to work using the Onsubmit code.🙂

Why are you using the plugin to pull the username - that's available from the $my or $user Object?



When I first started playing around with CF, I had it pulling the username from the profile plugin because when I read the tooltip in the plugins tab, I thought it sounded like what I needed and it had worked. I wasn't too keen on some of the other functions at the time.

Thanks again!
This topic is locked and no more replies can be posted.