Skip to Content Skip to Menu

Auto-approve selected registrations

  • autobahn
  • autobahn
  • OFFLINE
  • Posts: 202
  • Thanks: 38
  • Karma: 4
10 years 3 months ago #246845 by autobahn
Replied by autobahn on topic Auto-approve selected registrations
Thank you for your patience.

I couldn't work out what you meant by 'the below' so do you mean I can put this query

UPDATE `#__comprofiler` SET `approved`= '1' WHERE `user_id` = '[user_id]'; UPDATE `#__users` SET `block`= '0' WHERE `id`= '[user_id]'


into the Activation box of SQL Query 1 for the Plan and it will result in registrations that are paid online being approved automatically?

Would it also follow that when a Pending Payment is Completed (using the Basket's Pay button) the update would run on that subscription?

We don't need the update to do anything else. The normal 'on activation' email is all that goes out when the payment is completed (in fact this is what brought the problem to light as new users who paid online were getting login credentials but couldn't log in because they hadn't been Approved).

Nothing depends on the approval triggers or the welcome email.

Thank you for considering the option of a new type of CB Auto Action as well.

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

  • autobahn
  • autobahn
  • OFFLINE
  • Posts: 202
  • Thanks: 38
  • Karma: 4
10 years 3 months ago #246882 by autobahn
Replied by autobahn on topic Auto-approve selected registrations
Thanks Nant. It was this tutorial that helped me determine the SQL update that I need.

Basically, we want to approve a registration/subscription at the point where it is activated as a result of payment being completed. Payment can be online at the time of registration by PayPal or offline by cheque etc. (maybe days later)

If I put this query

UPDATE `#__comprofiler` SET `approved`= '1' WHERE `user_id` = '[user_id]'; UPDATE `#__users` SET `block`= '0' WHERE `id`= '[user_id]'

into the Activation box of SQL Query 1 for the Plan will it do what we want?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
10 years 3 months ago - 10 years 3 months ago #246900 by krileon
Replied by krileon on topic Auto-approve selected registrations
Believe there needs to be a linebreak after ; for it to parse multiple queries at once, but yes that query would set the users approval state and change their block status. However, I strongly suggest using CB Auto Actions and a code action as follows.

Action: Code
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditional 1: [var3] Equal To PLAN_ID_HERE
Conditional 2: [var2] Equal To A
Method: PHP
Code:
Code:
global $_PLUGINS, $ueConfig; $user = CBuser::getUserDataInstance( (int) '[user_id]' ); $_PLUGINS->trigger( 'onBeforeUserApproval', array( $user, 1 ) ); $user->approved = 1; $user->storeApproved( false ); if ( $ueConfig['emailpass'] == "1" ) { $user->storePassword( false ); } activateUser( $user, 1, 'UserApproval', false ); $_PLUGINS->trigger( 'onAfterUserApproval', array( $user, 1, true ) );

The above should do normal PHP approval on the user after the PLAN_ID_HERE plan has been activated. This should allow normal approval emails and triggers to fire.


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.
Last edit: 10 years 3 months ago by krileon.

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

  • autobahn
  • autobahn
  • OFFLINE
  • Posts: 202
  • Thanks: 38
  • Karma: 4
10 years 3 months ago #246910 by autobahn
Replied by autobahn on topic Auto-approve selected registrations
Thank you so much for taking the time to create the code for me and the detailed information on how to set up the CB Auto Action. I set the method to PHP(eval) rather than PHP(create_function) which I trust is correct?

I understand some of the PHP but not all (I am a VB programmer, not PHP) so I copied and pasted the code as given.

I will keep an eye on the outcomes as we receive new registrations.

Once again, many thanks, especially for your patience :)

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
10 years 3 months ago #246926 by krileon
Replied by krileon on topic Auto-approve selected registrations
A lot of hosts disable eval. So if it errors you'll need to use create_function. Be sure to do test registrations manually instead of waiting for a user to register. I suggest cloning your site, implementing the action, and thoroughly testing on the clone so you live site is untouched until you're confident it meets 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.

Moderators: beatnantkrileon
Powered by Kunena Forum