Skip to Content Skip to Menu

Auto Action - add note to stream when cbsubs plan is renewed or purchased

6 years 1 month ago #307517 by kerry.kunzli
Hi, I'm stuck trying to simply add an item to the Activity Stream like:

John Smith has just renewed their xyz membership!
or
John Smith has just joined our team with their xyz membership!

I presume I need to point to an asset but I can't find any documentation on what the assets are.

Thanks, Kerry.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
6 years 1 month ago #307518 by krileon
There is no asset for such an activity entry. You'll have to make one up (e.g. "subscription.PLAN_ID.renew"). Then include whatever you want it to display in the Title and/or Message parameters. As for the trigger setup you'd likely just use the below.

Plan Active (Non-Renewal)
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A
3: [var7] Not Equal To R

Plan Active (Renewed)
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A
3. [var7] Equal To R

Plan Expired
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Not Equal To A

This should allow you to use an asset like subscription.[var3].STATUS in your auto actions. So for renewals you'd use subscription.[var3].renewal. For that trigger [var3] is the plan 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 or Create an account to join the conversation.

6 years 1 month ago #307519 by kerry.kunzli
Thanks Kyle.... I'll work on this tonight.

Is there a reference of what var's are used for what? I presume the are dependent on the trigger? How do I find out what to use if I need more cbsubs info?

Kerry.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
6 years 1 month ago #307531 by krileon

Is there a reference of what var's are used for what?

We've the below trigger documentation that can at least give you an idea what variables are available to a trigger.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18358-using-cb-triggers

Once we've rewrote how we handle triggers we'll be improving our phpdoc for them then be able to parse out that phpdoc into documentation to significantly improve the information available for each trigger, but that won't be for awhile. There's no harm in asking on the forums though as we'd be glad to explain.

How do I find out what to use if I need more cbsubs info?

For that trigger specifically the variables are as follows.

Code:
/** * Called at each change of user subscription state due to a plan activation or deactivation * * @param UserTable $user The user owning the $subscription with that $planId * @param string $status New status: 'A'=Active, 'X'=Expired, 'C'=Cancelled * @param int $planId Plan Id which is changing status * @param int $replacedPlanId Replaced Plan Id in case of an upgrade * @param ParamsInterface $integrationParams Integration parameters for that plan $planId * @param string $cause 'PaidSubscription' (first activation only), 'SubscriptionActivated' (renewals, cancellation reversals), 'SubscriptionDeactivated', 'Denied' * @param string $reason 'N' new subscription, 'R' renewal, 'U'=update ) * @param int $now Unix time * @param cbpaidSomething $subscription Subscription/Donation/Merchandise record * @param int $autorenewed 0: not auto-renewing (manually renewed), 1: automatically renewed (if $reason == 'R') * @return void */ public function onCPayUserStateChange( $user, $status, $planId, $replacedPlanId, $integrationParams, $cause, $reason, $now, $subscription, $autorenewed )

So for example var1 is the $user object. To get the users user id from that variable you'd just use [var1_user_id] (but typically you're fine just using [user_id] since that variable is detected as the User for that auto action).


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.

6 years 2 weeks ago - 6 years 2 weeks ago #307832 by kerry.kunzli
Thanks Kyle.

One more thing... Is there a way to have the activity stream use [name] instead of username for the system actions and auto actions?

Example "username updated their profile picture"... instead have "[name] updated their profile picture"

Kerry.
Last edit: 6 years 2 weeks ago by kerry.kunzli.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
6 years 2 weeks ago #307842 by krileon
The name displayed is entirely based off what the formatname field displays, which uses the "Name Format" parameter within CB > Configuration > General. There is no means of adjusting the name output only for streams; it's all handled globally via that field.


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.
The following user(s) said Thank You: kerry.kunzli

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

Moderators: beatnantkrileon
Powered by Kunena Forum