Skip to Content Skip to Menu

Need some help with CB Auto Actions please

2 years 10 months ago #327194 by 3cellhosting
Need some help with CB Auto Actions please was created by 3cellhosting
Hello all,

I stand to be correct but I think CB Auto Actions is the tool but I can't get my head around how to set it up for the following scenario.

Client offers a free period with a paid for plan. Some users start the process but don't make payment so the transaction is incomplete. The end result is that my client is deleting 20+ users a day (mainly Russian) as the site only wants paid members.

During the process the registrant is added to membership as registered. Whilst they are not enabled and confirmation is pending they appear to be approved. Is it possible to use auto actions to delete the user if they abandon their basket rather than manually delete users each day?

Many thanks
David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48424
  • Thanks: 8274
  • Karma: 1443
2 years 10 months ago #327200 by krileon
Replied by krileon on topic Need some help with CB Auto Actions please
We don't provide an auto action for deleting users on purpose as it's too prone to accidentally wiping out your database if misconfigured. It is doable to delete a user from within CB Auto Actions though. You would need to use a Code action with the following.

Global
Triggers: None
Type: Code
User: Automatic
Access: Registered
Allow Direct Access: No (set this after saving the auto action for the first time)
Conditions
Condition 1
Field: confirmed
User: Action User
Operator: Equal To
Value: 0
Condition 2
Field: block
User: Action User
Operator: Equal To
Value: 1
Action
Method: PHP
Code:
Code:
$user->delete();

That will delete the user if they're unconfirmed and blocked.

Now as for deleting users who abandoned their cart that's a bit more tricky as the basket could be pending. So on top of needing to know which users profiles are not fully registered you also need to know which users either don't have a basket or the basket is still in its initialized state.

The best way to do that is probably the batching feature. Create the following Batch within CB Auto Actions to grab a list of such users.

Global
Users: All Users
Access: Registered
Actions
SELECT_YOUR_DELETE_USER_AUTO_ACTION_HERE
Basic Filter
Filter 1
Field: confirmed
Operator: Equal To
Value: 0
Filter 2
Field: block
Operator: Equal To
Value: 1
Advanced Filter
JOIN:
Code:
LEFT JOIN `#__cbsubs_payment_baskets` AS b ON b.`user_id` = c.`id`
WHERE:
Code:
b.`id` IS NULL

This will batch process through all users that are blocked, unconfirmed, and do not have a basket. CBSubs will expire unpaid baskets based off your CBSubs settings so it's best to just ignore any user without a basket. You'd simply run the batch URL via a CRON cURL GET call on a schedule and it should automatically take care of deleting those users. You can use the Batch feature like this or to do any kind of regular scheduled processing on users.

Please be sure you thoroughly test this on developer environment. A clone of your site. ANYTHING but your live data. Automating the deletion of users is dangerous so again be careful with this.


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