Skip to Content Skip to Menu

[SOLVED] Add Member Since & Ending Date date fields

  • hac
  • hac
  • OFFLINE
  • Posts: 50
  • Thanks: 1
  • Karma: 0
10 years 1 month ago - 10 years 3 weeks ago #249837 by hac
Hi,

We have a Joomla 3.3.x site with CB 1.9.1 and CBSubs 3.0.0.

In CB I have a Member Since date field (cb_membersince) and an Ending Date field (cb_endingdate).

What I want to do, is add the date to the Member Since field when the user subscribes to a plan AND there isn't already a date in the field. So, this field will only be filled in the first membership they take out.

Also each time that a user subscribes to a plan I want to update their Ending Date CB field to the plan's expiration date.

I tried to use an Auto Action to add the Member Since date, but it isn't working. Here is how I set it up:
Type: Field
Triggers: onCPayAfterPaymentStatusUpdateEvent
User: Automatic
Access: Everybody
Conditionals: [var3] less than or equal 2 <- my plan ids are 1 and 2
[var2] Equal to A
[cb_membersince] Equal to NULL
Field Actions:
Field: Member Since Date <- cb_membersince
Operator: Set (Field=Value)
Value: [cb:date format="Y-m-d" /]

I looked in the database and the cb_membersince field has NULL in it after the user registers.

Then once that is working, I need to add the Ending date update field action but I don't know how to get the expiry date. I haven't been able to find any CBSubs substitions.

Field: Last Expiry Date <-cb_endingdate
Operator: Set (Field=Value)
Value: <- don't know what to put in here.

Maybe there is an easier way to do this?

Thank you for your help on how to do this.
Last edit: 10 years 3 weeks ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8283
  • Karma: 1443
10 years 1 month ago #249857 by krileon
Replied by krileon on topic Add Member Since & Ending Date date fields
To combine to date fields I suggest using CB Query Field then in your database query do the calculation using MYSQL date functions. CB Auto Actions can't combine two date fields like what you're wanting to do without using a Query action and MYSQL functions or a Code action with PHP.


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.

  • hac
  • hac
  • OFFLINE
  • Posts: 50
  • Thanks: 1
  • Karma: 0
10 years 1 month ago #249877 by hac
Hi Kyle,

The Member Since doesn't have any date calculation or combining of any fields. It should just put the current date into the Member Since field, if it doesn't already have a date in it. Can't I use an auto action like I showed below to add the current date?

For the Ending Date field, it doesn't need a calculation either, it just needs to have the member's expiry date put in the field.

The admin has to be able to edit either of these fields, if they need to. So, a query field wouldn't work for the Ending Date field.

Thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8283
  • Karma: 1443
10 years 1 month ago #249908 by krileon
Replied by krileon on topic Add Member Since & Ending Date date fields
onCPayAfterPaymentStatusUpdateEvent isn't the correct trigger to be using for subscription state changes. You need to use the following.

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

Plan Expired
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditional 1: [var3] Equal To PLAN_ID_HERE
Conditional 2: [var2] Equal To X

Trying to modify user data on the trigger you're currently using will likely just result in the data being overridden shortly after it by CBSubs since CBSub is still acting off a reference.

To get the subscription expiration date from onCPayUserStateChange you should be able to use the below substitution. The var9 is the subscription object for that trigger.

[var9_expiry_date]


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.

  • hac
  • hac
  • OFFLINE
  • Posts: 50
  • Thanks: 1
  • Karma: 0
10 years 4 weeks ago #249958 by hac
Hi Kyle,

Thank you for your help once again. I now have the Ending Expiry date working, but I still can't get the Member Since one working.

It must be the condition of checking the Member Since field that is causing the issue. I tried checking if it was Equal To NULL and also if it was Empty, but neither is triggering.

When I look at the comprofiler table record the cb_membersince field is showing NULL as the contents of the field, when it hasn't had anything added to it yet.

I tried this condition:
Conditionals: [var3] less than or equal 2 <- my plan ids are 1 and 2
[var2] Equal to A
[cb_membersince] Equal to NULL

and this condition:
Conditionals: [var3] less than or equal 2 <- my plan ids are 1 and 2
[var2] Equal to A
[cb_membersince] Empty

So, how do I check for the cb_membersince field being NULL?

Thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8283
  • Karma: 1443
10 years 4 weeks ago #249989 by krileon
Replied by krileon on topic Add Member Since & Ending Date date fields
If membersince is a Date field then it's never empty. You'd need to condition against 0000-00-00 00:00:00 if it's datetime or 0000-00-00 if it's date.


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