[SOLVED] Auto Action Question

10 years 1 month ago #243696 by krileon
Replied by krileon on topic Auto Action Question

So in my situation when I'm using the autoaction trigger 'onAfterUserApproval' the following fields are available for substitution without using getfields:

Yes, but based off your usage you probably should be using the after registration trigger.

Here's what I just tried in my Auto Actions PHP code block. I'm using substitutions as you mentioned in your last post. The code follows and the error it generated is included as well. Any suggestions would be appreciated.

Your PHP is not valid. You need to escape your substitutions with quotes when in PHP. Example as follows.

$username = '[username]';

While that got rid of the error, I still don't get a new user in the backend system. Shouldn't Auto Action be able to execute code like this?

Your usage is not valid. You don't declare and set a variable when sending to a function like that. For example your usage should probably be as follows.

$New_User_Id = VtInsert( '[username]', $RandPass, '[email]', '[firstname]', '[lastname]' );

Let me continue the topic this way. I'm setting up CBSubs and want to create subscription based user accounts in Vtiger. I've been trying to do this through AutoAction with little success, but I'm curious if there is a better way. Is there a better way to user accounts in Vtiger when CBSubs is being used? Has anybody done this before?

CB Auto Actions or a custom plugin are the best ways to do this. A custom plugin would just be doing the same as CB Auto Actions and execute PHP on a trigger.


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 to join the conversation.

10 years 1 month ago - 10 years 1 month ago #243715 by rmwalker
Replied by rmwalker on topic Auto Action Question
No offence intended, but you must not have looked at my latest posts. Finally I have success at about 3:00AM last night. Here's the code I ended up with in the AutoAction code block:
include 'butler/include/Butler.php';

$userpass = Vt_Rand_Str(10);
$New_User_Id = VtInsert($newuser = '[username]', $newpass = $userpass, $newemail = '[email]', $newfirstname = '[firstname]', $newlastname = '[lastname]', $newaddress = '[cb_address]', $newcity = '[cb_city]', $newstate = '[cb_state]', $newcountry = '[cb_country]', $newzip = '[cb_zipcode]', $newphone = '[cb_phonenumber]', $newmobile = '[cb_phonenumber]');

Many thanks for your help!

Please Log in to join the conversation.

10 years 1 month ago #243721 by rmwalker
Replied by rmwalker on topic [SOLVED] Auto Action Question
Thanks again for your help on the Auto Action issue. I understand (now) about using fields substitution to get and use existing values in a users CB profile. How do we post values back into that same users CB profile?

Please Log in to join the conversation.

10 years 1 month ago #243731 by rmwalker
Replied by rmwalker on topic [SOLVED] Auto Action Question
So if I understand the way things are done. I could add 4 more lines to my code and populate two fields in the user's profile. Does this look right or do I need to do a store() after each set statement?
include 'butler/include/Butler.php';
 
$userpass = Vt_Rand_Str(10);
$New_User_Id = VtInsert($newuser = '[username]', $newpass = $userpass, $newemail = '[email]', $newfirstname = '[firstname]', $newlastname = '[lastname]', $newaddress = '[cb_address]', $newcity = '[cb_city]', $newstate = '[cb_state]', $newcountry = '[cb_country]', $newzip = '[cb_zipcode]', $newphone = '[cb_phonenumber]', $newmobile = '[cb_phonenumber]');

$cbUser =& CBuser::getInstance( $user->id );
$cbUser->set( 'cb_jbid', $New_User_Id );
$cbUser->set( 'cb_jbactive', 'Yes' );
$cbUser->store();

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.578 seconds

Facebook Twitter LinkedIn