1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Value of the user's id - form plugin

Discussion in 'Professional Support' started by erricogiu, Jul 12, 2018.

  1. erricogiu

    erricogiu New Member

    Level: Community
    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:

    but I do not get results

    I attach the data of the elements so they can help me in a concrete way.
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    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}';
  3. erricogiu

    erricogiu New Member

    Level: Community
    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!!
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    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
    $user_from = '{transferred_products___user_from_raw}'; //get the J!userid
    $myDb= JFactory::getDbo();

    ->where('id = '.$myDb->quote($user_from));


    return $email;
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    There's actually an easier way, using JFactory::getUser() ...

    Code (Text):

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

Share This Page