Skip to Content Skip to Menu

Extending CBSubs functionality in custom component

7 years 4 months ago #295293 by webtechplus
Hi I was wondering if there was a function or something I could call when a subscription plan is successfully purchased?

Our custom component allows particular groups to post items to a website. Each subscription they will get X amount of points.

Every time a user posts an item, 1 point is subtracted. An additional point is subtracted if a user wants to promote this post.

So what I want to do is when a plan is purchased, depending on the plan, a user will receive so many points (eg 5). I just don't know how to trigger this or extend the CB functionality. I did come across something about an API but couldn't find much documentation about it.

Thanks


Thanks for support and feedback
We hope that we can assist you if you need and ask, all the best from the WTP Team

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
7 years 4 months ago #295316 by krileon
CBSubs SQL Actions can execute a database query based on plan activate and deactivate states. So if all you need to do is execute a query that'd work. If you need to execute PHP like a 3rd party API you'll need to use CB Auto Actions and a Code action with the below usage.

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

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


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.

7 years 4 months ago #295369 by webtechplus
Replied by webtechplus on topic Extending CBSubs functionality in custom component
Thanks I had a bit of a look in Auto Actions but I wasn't sure how to execute PHP code. I got up to the point of entering PHP code but when I internally executed the action nothing displayed. Is there any examples or tutorials on entering the PHP code or referencing a particular PHP file?

These are the settings:
Global
Triggers: None
Type: Code
User: Manually
User Variable: Variable 1
Access: Everybody

Conditions
N/A

Action Tab
Method: PHP
Code: echo "Hello World";
Return: Tried Silent, echo and var_dump

Parameters
Defaults

I didn't get anything displayed when I clicked on Click to Execute


Thanks for support and feedback
We hope that we can assist you if you need and ask, all the best from the WTP Team

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
7 years 4 months ago #295379 by krileon
Any PHP executed in a Code action is done in an anonymous function. This means you need to do a return in your code and set the code output to echo if you really want an echo. Note the CBSubs triggers above don't have any output so trying to output your code during them will result in nothing displayed.


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