Getting email address of user from another table

I have a form in which I want emailed to a user that is selected in the employee element.

I am looking for an easier way to find the email address on the email plugin without having to place a auto fill element for the email address on the second form.
 
I'm assuming "the employee element" is a join to an "employee" table?

In which case, an "Email to (eval)" would do it ...

Code:
$employeeId = '{yourtable___employee_raw}';
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('email')->from('employees')->where('id = ' . $myDb->quote($employeeId));
$myDb->setQuery($myQuery);
return $myDb->loadResult();

Change the placeholder and table/field names to suit.

-- hugh
 
Why not just
Code:
$user = JFactory->getUser('{yourtable___employee_raw}');
return $user->email;

or even

return JFactory->getUser('{yourtable___employee_raw}')->email;
 
Because (if I understand him correctly) he's not talking about J! user ID's, he's talking about a join to his own 'employee' table.

-- hugh
 
Not as-is, no, as the cron plugin doesn't have the same "Email to (eval)" option, I'd have to add it as an option, which would be billable time.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top