Skip to Content Skip to Menu

CBSubs triggering PHP code ?

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
1 year 6 months ago #333492 by rbuelund
CBSubs triggering PHP code ? was created by rbuelund
I have a PHP code that is sending out an SMS based on the user id. It works as an auto action which I can trigger manually with the "Internal action URL"  but I would like it to trigger automatically 14 days after the subscriptions have run out - is that possible in any way ?

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
1 year 6 months ago - 1 year 6 months ago #333499 by krileon
Replied by krileon on topic CBSubs triggering PHP code ?
CB Auto Actions doesn't have a scheduler built in so no there isn't anyway to schedule an action to run after a specific event. That's something we'll be able to support in CB 3.x as we've plans to implement a generic job queue that'd be able to do this and more.

For now the only thing I can think of is to use CBSubs Mailer to schedule an email to be sent then act on the onCPayBeforeMailerEmailMessageSent trigger to send your SMS. The triggers variables are as follows.

Code:
$_PLUGINS->trigger( 'onCPayBeforeMailerEmailMessageSent', array( $this->user_id, $this->automessage_id, &$mailFrom, &$mailFromName, &$mailToName, &$mailTo, &$subject, &$body, $this->emailhtml, &$mailCC, &$mailBCC, &$mailAttachments, &$mailReplyTo, &$mailReplyToName ) );


You could also have it to try to send a private message and act on its trigger if you don't want to send an email, but email + SMS might be a pretty good reminder combo.

Code:
$_PLUGINS->trigger( 'onCPayBeforeMailerPrivateMessageSent', array( $this->user_id, $this->automessage_id, &$subject, &$body ) );


Both methods will fire the below trigger if successfully sent and is another trigger option

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

All 3 give you the most important thing, their user id, as the first variable. The second being automessage_id, the second variable, that'll be the id of the mailer being sent and you'll want to condition against that so you only send the SMS for that specific mailer.


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.
Last edit: 1 year 6 months ago by krileon.

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

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
1 year 6 months ago #333532 by rbuelund
Replied by rbuelund on topic CBSubs triggering PHP code ?
So if I understand you correctly: in the top of the auto actions code field I would insert:


if ($this->automessage_id != 105) exit;

To only send sms' when the mailer with id=105 is fired ?

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

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
1 year 6 months ago #333533 by rbuelund
Replied by rbuelund on topic CBSubs triggering PHP code ?
..and would I not still be able to use [user_id] in the code field to get the user id or should i use:$this->user_id

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
1 year 6 months ago #333535 by krileon
Replied by krileon on topic CBSubs triggering PHP code ?

So if I understand you correctly: in the top of the auto actions code field I would insert:


if ($this->automessage_id != 105) exit;

To only send sms' when the mailer with id=105 is fired ?

No, you can't use $this directly. You need to access them as var1, var2, var3, etc.. $this->automessage_id is var2 so you can substitute its value in with [var2] or access it directly with $variables in a Code action when using PHP. Example as follows using the substitution.
Code:
if ( (int) '[var2]' !== 105 ) {     return; } // SMS CODE HERE

..and would I not still be able to use [user_id] in the code field to get the user id or should i use:$this->user_id

Use [var1] to get the recipient user id. You can also set User to Manually and select Variable 1 for the User Variable parameter. Now you can use normal substitutions like [user_id], [username], etc.. to get that users information.


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.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
1 year 6 months ago #333542 by rbuelund
Replied by rbuelund on topic CBSubs triggering PHP code ?
Perfect - thank you!

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

Moderators: beatnantkrileon
Powered by Kunena Forum