Forums

Passing user db info to a tcpdf output

MaestroC 11 Oct, 2015
I have a form that sends its data to a pair of TCPDF actions, each one slightly different than the other. I need to show the logged in user's Joomla name and email field in the tcpdf output. These two user fields are not being used anywhere in the form itself, they only show up on the pdf output.

I have read the documentation on adding a custom action to the onload event and have added this code to it:

<?php
$user = JFactory::getUser();
$form->data['user_name'] = $user->name;
$form->data['user_email'] = $user->email;
?>

I then added the following code to the tcpdf html:

<p>Coach Name: {user_name} ({user_email})</p>

But as you can probably guess it doesn't work. Am I writing things incorrectly or do I need to put something in the form itself to store those variables so that they get sent on to the TCPDF action? Those two fields are not being stored in the form database anywhere.
GreyHead 12 Oct, 2015
Hi MaestroC,

The code looks OK but the Custom Code action needs to be in the On Submit event before the TCPDF action.

If, for some reason, you did need them in the On Load action you could pass the data using hidden inputs but that's not needed here.

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