Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

[#4970] Add 1 point after login

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 2 days ago - 9 years 11 months ago #255346 by dotcom22
[#4970] Add 1 point after login was created by dotcom22
hello

1) I setup Auto-Action "Field" for add 1 point each time user login. Points are stored inside integer field cb_points. Now I would like add some restriction for allow 1 point to be addedd but only every 24h. I suppose I must set conditions for check last visit date/time value (a Joomla field?) user was connected AGAINST actual date/time when user login.

Any clue ?

2) I would like also display a kind of alert message such "Congratulation, you won 10 points" when action is fired. Fields action do not permit that, so I suppose I must try something with Code action ?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 9 years 11 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
10 years 2 days ago #255373 by krileon
Replied by krileon on topic Add 1 point after login

1) I setup Auto-Action "Field" for add 1 point each time user login. Points are stored inside integer field cb_points. Now I would like add some restriction for allow 1 point to be addedd but only every 24h. I suppose I must set conditions for check last visit date/time value (a Joomla field?) user was connected AGAINST actual date/time when user login.

You can condition with the [lastvisitdate] substitution. CB Auto Actions supports a number of inline PHP functions for conditions, especially date handling. See "Format Functions" on the Conditions tab of your action at the bottom. You could take the last visit date, add 1 day using strtotime then compare it to todays strtotime date using [cb:date format="Y-m-d H:i:s" /]. Example as follows.

strtotime(+1 DAY,[lastvisitdate]) Less Than strtotime([cb:date format="Y-m-d H:i:s" /])

2) I would like also display a kind of alert message such "Congratulation, you won 10 points" when action is fired. Fields action do not permit that, so I suppose I must try something with Code action ?

You could use a Code action to echo this on the users profile with the before profile display trigger or to add a message queue using the $_CB_framework->enqueueMessage( MSG, TYPE ) function. Another option is to do a redirect on the after login trigger and add your message as the redirect message. You could also output the message using a Custom HTML field and substitution IF statements. Basically you've a lot of options; pick which best fits your needs.


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 1 day ago #255437 by dotcom22
Replied by dotcom22 on topic Add 1 point after login
Code:
strtotime(+1 DAY,[lastvisitdate]) Less Than strtotime([cb:date format="Y-m-d H:i:s" /])


I tested your condition as is but I still get points and alert message (made with separate Redirect action) even if 24h are not already past. I looked and you provided US date format so I modified in d-m-Y H:i:s because my time zone is European but no change. I don't know what wrong. I used latest auto-action and I even latest nightly build. I checked Date Format in CB configuration and is dd/mm/yyyy format.

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
10 years 1 day ago #255477 by krileon
Replied by krileon on topic Add 1 point after login
The format is database formatted, don't change it. Enable debug mode under Parameters then enable debug mode and maximum error reporting in Joomla global configuration. Now test your action and see what debug info it dumps. When action debug mode is enabled it'll var_dump any action failures.


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 1 day ago - 10 years 1 day ago #255488 by dotcom22
Replied by dotcom22 on topic Add 1 point after login
Ok I enabled debug...but then from where I must see info ? frontend or backend or no matter from where ? Or maybe just After login ? Then on the Joomla Debug Console I must look on Database Queries Tab I suppose?

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 10 years 1 day ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
10 years 1 day ago #255492 by krileon
Replied by krileon on topic Add 1 point after login
You need to have the actions debug mode enabled under Parameters while editing your action. Next in Joomla global configuration you need to enable debug mode and set error reporting to maximum. Now you need to test your action. Since your action works off login, simply login; if the action fails at a conditional or access check it'll dump that information and stop the redirect during login and show it to you.


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