Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 31)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Mail auto action question...

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 395
  • Thanks: 36
  • Karma: 2
  • Add-ons
1 year 6 months ago #334178 by liaskas
Mail auto action question... was created by liaskas
Hello...
We need to create an auto action that will send a notification mail to specific usergroup(s) users if an activity post is created by a user that belongs to a specific usergroup.

Example:

User A that belongs to usergroup A creates an activity post.

The auto action that we need will send an e-mail to all the users that belong to usergroup A and usergroup B.

How can we create such an auto action?

Than you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 6 months ago #334180 by krileon
Replied by krileon on topic Mail auto action question...
You'll probably need to use PHP to do this efficiently as you'd want to batch all the emails together into a BCC so your site only has to send 1 email to reach all the recipients. As for acting on activity create you'd use the activity_onAfterCreateStreamActivity trigger shown below (var3 being the activity entry).
Code:
$_PLUGINS->trigger( 'activity_onAfterCreateStreamActivity', array( $stream, $source, $row ) );

Example as follows.

Global
Triggers: activity_onAfterCreateStreamActivity
Type: Code
User: Automatic
Access: USERGROUP_A_HERE
Action
Method: PHP
Code:
Code:
PHP CODE TO QUERY FOR USERS AND EMAIL THEM

You can use Joomla and CB API in your code action or just native PHP, but you'd basically need to query for the list of users you want to email and set their email addresses into the BCC.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • liaskas
  • liaskas
  • OFFLINE
  • Posts: 395
  • Thanks: 36
  • Karma: 2
  • Add-ons
1 year 6 months ago #334184 by liaskas
Replied by liaskas on topic Mail auto action question...
Thank you for your reply Krileon.

Could you be so kind to provide a php code example for sending these mails to...

Administrators (id = 7) and Editors (id = 4) as i am not a php programmer?

Thank you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 6 months ago #334186 by krileon
Replied by krileon on topic Mail auto action question...
We do not provide coding assistance outside the business membership, sorry. This is beyond a simple example and is a specific usecase.

The only non-coding option would be to chain auto actions, but that will result in 1 email sent per recipient instead of a single email sent with BCC, which is fine if we're talking maybe 10 or so recipients, but if it's a lot it really should be done as BCC. I can provide an example of how to do this, but the warning is it isn't sustainable as a growing site will slam your mail server if it has to send out to a lot of recipients.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 6 months ago #334187 by krileon
Replied by krileon on topic Mail auto action question...
As a side note I'll see if I can quickly improve the Email action to support custom query for recipients. Then all you'd need is a simple database query for the recipients.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
1 year 6 months ago #334189 by krileon
Replied by krileon on topic Mail auto action question...
Ok, latest CB Auto Actions build release now supports Query and Code recipients. This makes it a bit easier, but you'll still need some custom coding. It however is simple enough that I can provide an example.

Global
Triggers: activity_onAfterCreateStreamActivity
Type: Email
User: Automatic
Access: USERGROUP_A_HERE
Action
To: none
Subject: EMAIL_SUBJECT_HERE
Body: EMAIL_BODY_HERE
BCC: query
BCC Query:
Code:
SELECT DISTINCT u.`email` FROM `#__users` AS u INNER JOIN `#__user_usergroup_map` AS g ON g.`user_id` = u.`id` WHERE g.`group_id` = USERGROUP_ID_HERE

Note be sure you set "To" to literally the word none as it suppresses the To address entirely for a BCC only email. Same with "BCC" being literally set to the word query. Both are noted in parameter descriptions. Replace USERGROUP_ID_HERE with the id of the usergroup you want to check for. Adjust the query as needed if you need to check for more than 1 usergroup. This should then email all those users as BCC.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum