Notify gallery photo owner when comment added

1 year 9 months ago #329798 by yeatea
Joomla! 3.10.9
MariaDB 10.3.34
CB 2.7.2+build.2022.05.09.18.01.50.cff9cffac

A few months ago you advised me how to set up CB Gallery in a GroupJive group, and disallow it in Profiles. This allowed my club members to upload photos only to a specific gallery and other members to comment/critique them. This is working well - thank you.
I have now been asked to see if we could email the owner of a photo when a new comment is added by another member. I can set up an email Auto Action based on trigger "activity_onAfterCreateComment" and this works, but obviously using "[userid]" or "[mail]" in the "to" field sends the email to the triggering user. I do not know how to get the email or userid of the member whose photo has been commented on. Ideally I would also like to include the title of the photo in the text of the email.
Could you advise me if this is possible, and how to proceed please. I am not familiar with assets and variables, so if these are required could you explain in as simple a fashion as possible - thanks in advance.

Please Log in to join the conversation.

1 year 9 months ago #329812 by krileon
Replied by krileon on topic Notify gallery photo owner when comment added
Make a copy of the "CB Gallery - Comment Notification" system action and change its Type to Email. Next set To to [var2_user_id] and that should email the person that owns the gallery entry. To get the user id of the user making the comment you'd use [var3_user_id]. You can then use our nested substitution feature to get more information like their name such as in the following example.

[cb:userfield field="formatname" user="[var3_user_id]" /]


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 to join the conversation.

1 year 9 months ago #329828 by yeatea
Excellent - thanks for your quick reply. That works fine.

As previously mentioned I have no experience with modern coding systems (retired from mainframe programming 30 years ago), and i appreciate you cannot train all your customers, so forgive the next question.
From your trigger document I can see that "activity_onAfterCreateStreamComment" takes 3 parameters, the second of which (var2?) appears to be the user being viewed, and the third (var3?) appears to be the result which seems to be database row in "...comprofiler_plugin_activity_comments". Is there a way of rerieving the title of the item commented on other than extracting the item id from the asset, and then querying the gallery_items table?

Please Log in to join the conversation.

1 year 9 months ago #329832 by krileon
Replied by krileon on topic Notify gallery photo owner when comment added
You can access variables directly using substitutions. So for example if var2 is a user object then [var2_username] would return their username. For activity_onAfterCreateStreamComment specifically though the variables are as follows.

$_PLUGINS->trigger( 'activity_onAfterCreateStreamComment', array( $stream, $source, $row ) );

var1 is the comment stream object. var2 is the source object of the comment (in this case it will be the gallery media object), and var3 is the actual comment object. So if you want the title you'd use [var2_title].


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 to join the conversation.

1 year 9 months ago #329838 by yeatea
That's excellent - thanks very much for your help

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.290 seconds

Facebook Twitter LinkedIn