• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Email plugin

jh

Member
Hi

I was setting up some email plugins which are working fine however one that I can not work out is:

How to email the original submitter of the details that their record has been used on another form (via database join). The record has a 'submitted by' user element/id field, and I want them to be emailed when someone 'uses' that record. Hope this makes sense.

Kind Regards
 
You'd have to use the "Email to (eval)" feature, to get the email from the user id of the related record.

Code:
// get the join's value (foreign key), replace yourtable___yourjoin with the full element name, leave the _raw suffix
$joinId = (int)'{yourtable___yourjoin_raw}';
if (!empty($joinId)) {
   $db = JFactory::getDbo();
   $query = $db->getQuery(true);
   // replace yourtable and userid with your table name and user field name as appropriate
   $query->select('u.email')->from('yourtable')->leftJoin('#__users AS u ON u.id = yourtable.userid)->where('yourtable.id = ' . $joinId);
   $db->setQuery($query);
   return $db->loadResult();
}
return '';

-- hugh
 
Hi

Thank your for your message. So if table 1 is named 'object_table' with user field name 'sub' and table 2 is named 'collection_new' with the database join field 'collection_new___datajoin' should this work? (I want the user who submitted the record to be emailed when someone adds it to their own list)


// get the join's value (foreign key), replace yourtable___yourjoin with the full element name, leave the _raw suffix
$joinId = (int)'{collection_new___datajoin_raw}';
if (!empty($joinId)) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// replace yourtable and userid with your table name and user field name as appropriate
$query->select('u.email')->from('object_table')->leftJoin('#__users AS u ON u.id = object_table.sub)->where('object_table.id = ' . $joinId);
$db->setQuery($query);
return $db->loadResult();
}
return '';

Thank you for your help.
 
Hi

Thank you I have tried this and got an error page:

syntax error, unexpected 'object_table' (T_STRING), expecting ',' or ')'

Is there something I might have done wrong?

Many thanks
 
Thank you both, works perfectly.

Could I ask how to get placeholders for the email from the list containing the foreign key (the new form does not contain the data, only the db join)

Thank you very much for your help.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top