[SOLVED] Auto Action before or after CBSubs Mailer sent

6 years 5 months ago - 6 years 5 months ago #298966 by lousyfool
Hi,

When CBSubs Mailer sends a specific email (just before or just after doesn't matter), I need to have a specific CB field changed for the recipient of the email.

So, I'm setting up an Auto Action as follows:

Global
Triggers: onCPayAfterMailerMessageSent (or onCPayBeforeMailerEmailMessageSent)
User: Automatic
Access: Everybody
Conditions
1: [var1] Equal To [user_id]
2: [var2] Equal To 7 (this happens to be the mailer ID)
All other settings, like in the Parameters tab, are default.

However, it doesn't work with either trigger, the field change doesn't happen, and neither do other action types I tested with. Am I doing something wrong, e.g. with the conditions?

Just in case these triggers don't work as I'd expect from their naming:
The need is to fire an event such as the CB field change a certain time before a subscription expires, which happens to be when the respective Mailer is sent. I can't see any other way to do so without way more effort, or am I overlooking something?

Thanks for your help!

Please Log in to join the conversation.

6 years 5 months ago #298990 by krileon
Your first condition won't match. The person activating the trigger is likely an empty user object as that's typically ran from CRON or it's your own user if you clicked the URL. So you're checking that [var1] (user id email was sent to) is matching empty user id (which is 0) which will never match. You should be able to just remove that condition then use the following.

User: Manually
User Variable: Variable 1

This should force it to use a user object built from the user id in var1. You should then just be able to use a Field action as normally to alter their fields value.


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.

6 years 5 months ago - 6 years 5 months ago #299007 by lousyfool
Replied by lousyfool on topic Auto Action before or after CBSubs Mailer sent
Thanks Kyle,

Tried what you were suggesting, but it still doesn't work, no field change.

So, now I'm having

Global
Triggers: onCPayAfterMailerMessageSent (or onCPayBeforeMailerEmailMessageSent)
Type: Field
User: Manually
User Variable: Variable 1
Access: Everybody
Conditions
[var2] Equal To 7 (the mailer ID)
Action (same as before my previous post)
Field: cb_xyz
Operator: Set (Field = Value)
Value: 0 (it's 1 now)
Translate Value: No
All other settings, like in the Parameters tab, are still default.

But still no joy.

Just so we're absolutely clear:
Yes, the mailer is run from CRON only, and that's working fine.
Yes, I need the field changed for the user the email was or will be sent to.

Thanks for taking another look at this!

Please Log in to join the conversation.

6 years 5 months ago #299009 by krileon
That trigger absolutely fires, but it's failing probably due to the condition of which I've no idea if is even correct. Try removing the condition and retry. You don't need the second trigger either, but just onCPayAfterMailerMessageSent which only fires if an email or private message was actually sent. That trigger is as follows.

$_PLUGINS->trigger( 'onCPayAfterMailerMessageSent', array( $this->user_id, $this->automessage_id, $subject, $body ) );

I would assume $this->automessage_id is the number under the Id column in CBSubs > Mailers, but it may not be. If you're using the number under the # column be sure to change it to the number under the Id column


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.

6 years 5 months ago #299015 by lousyfool
Replied by lousyfool on topic Auto Action before or after CBSubs Mailer sent
Thanks for the very prompt reply!

I had seen the trigger code, that's why initially I was already using [var2] with the mailer ID. And haha, of course I'm using the mailer ID, not the # number. Yup, the same as in the "id" column in #_cbsubs_mailer_automessages. :)

Try removing the condition and retry.

No way! Then it'll fire on each and every mailer (if it really fires), and that's a no-no... I have several mailers, but it must fire only before or after one of them: the one with ID 7.

Now what? :S

Please Log in to join the conversation.

6 years 5 months ago #299020 by krileon
Well I assumed you weren't doing this in a live environment. I guess you can enable debug mode under the Parameters tab of your auto action to see where it's failing or if it's even firing. You'll need to remove &format=raw from the mailer URL so you can see the message output if debugging catches anything. My advise is to stop messing with a live install and clone it then add some test users and test without a condition.


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.

Moderators: beatnantkrileon
Time to create page: 0.263 seconds

Facebook Twitter LinkedIn