Value of the user's id - form plugin

erricogiu

New Member
Hello,
I am working with a form plugin to send an email to a user.
One of the elements of the form is the user's id. From this id I can get the email address to send the message. I do this without problems. I use the function to access the database from the PHP code of the plugin with "JFactory :: getDbo ()". All ok.

The problem that seems simple, but I can not find a way to do it is to know the value of the user's id of the form!

Use Fabrik 3.8.1, Joomla Joomla! 3.8.8, PHP 7.0.30,

I try to follow the instructions of:
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/#accessing-form-data

but I do not get results

I attach the data of the elements so they can help me in a concrete way.
 
Can you give some more informations?
Your screenshot says you are using the form email plugin, WIKI "accessing-form-data" is for form php plugin.

What are your exact settings (PHP/HTML template? Article template? Message text directly?...)

Usually you should be able to get the form data with placeholders, something like
$product_id ='{transferred_products___product_id}';
 
Actually I try to use PHP code in "Email to (eval)" of the "email" plugin

But it does not work either if I try to use it in form php plugin.

The instruction that I try to use is
$ user_from = '{transferred_products___user_from}';
print "user_from:" $ product_id; exit;

and the result is the 3rd image that I attached.

Images 1 and 2 are the data that you ask me

Thank you!!
 
You are setting $user_from and printing the non-existing $product_id, what do you want to achieve?
"Email to (eval)" is for evaluating (and returning) an email address.

Your user element will store the J! userid as raw value (and contain whatever you've selected as value: name, username, email).
Asuming your user element is not showing the email then you must fetch the email from the database
http://fabrikar.com/forums/index.php?wiki/php-common-tasks/#select
e.g.
$user_from = '{transferred_products___user_from_raw}'; //get the J!userid
$myDb= JFactory::getDbo();
$myQuery=$myDb->getQuery(true);

$myQuery
->select('email')
->from('#__users')
->where('id = '.$myDb->quote($user_from));

$myDb->setQuery($myQuery);
$email=$myDb->loadResult();

return $email;
 
There's actually an easier way, using JFactory::getUser() ...

Code:
return JFactory::getUser((int)'{transferred_products___user_from_raw}')->get('email');

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

Thank you.

Members online

No members online now.
Back
Top