Skip to Content Skip to Menu

[SOLVED] How to edit a field just after user registration using auto action

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 11 months ago - 10 years 11 months ago #237290 by activha
To follow :

The problem is that the auto action correctly fires as the user is well registered on PAP

However fields are not updated for CB user as if the following lines would not work when a payment is asked :

$user = CBuser::getUserDataInstance( '[user_id]' );
$user->cb_refid = $affiliate->getUserid();

Does CBsubs stop something ?

I also tried
$user = CBuser::getUserDataInstance( '[user_id]' );
$user->storeDatabaseValue( 'cb_refid', $affiliate->getUserid() );

or even
$user->storeDatabaseValue( 'cb_refid', 'test');

but this storeDatabaseValue does not work here.
Last edit: 10 years 11 months ago by activha.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 11 months ago #237326 by krileon
storeDatabaseValue should work. If not you can try the below usage.

Code:
$user = CBuser::getUserDataInstance( '[user_id]' ); $user->cb_refid = $affiliate->getUserid(); $user->store();

The problem is you're trying to store a user that is in the middle of being stored and adjusted by CBSubs. So CBSubs is probably going to override any user object changes you make. You may want to try storing the affiliate later if possible, creating a new CB plugin to work with the user object by reference, or try doing a direct database query to add the value to the users database row.


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.

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 11 months ago #237332 by activha
Well the only solution after a lot of tests was a direct database query to add the value.

However it seems that CBsubs is interfering a lot as we also had problems with :
cbimport( 'cb.session' );
CBCookie::setcookie( 'PAPVisitorId', '[cb_codeparrainpartenaire]' );
with the trigger onCPayBeforeStorePaymentBasketUpdated

The field is not substituted.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 11 months ago #237341 by krileon
Because there's no user object to work off of. That trigger does not contain a user object. Try acting on the POST value if that field is available on registration using the below.

[post_cb_codeparrainpartenaire]

You will probably need 2 actions that do the same thing. The existing is fine, but only for logged in users in which case you should set it to only work for registered users. Next copy it and set it to apply to every user then use the after registration 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 or Create an account to join the conversation.

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 11 months ago #237386 by activha
As mentioned in the other post regarding PAP we used CBCookies to erase PAP cookies and then reset them correctly with the new cb_codeparrainpartenaire

It seems to work fine

Thanks a lot
The following user(s) said Thank You: krileon

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

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 7 months ago #242916 by activha
Hello Kyle

I am coming back on the store function with which we have a problem
We use it with afteruserupdate or afterupdateuser but it keeps looping in this case, looks like the auto action keeps thinking the user always updates

Is there a way to use the store() or storedatabasevalue and get out of this loop ?

Second question I use :
[var1_password] = [var3_password] as a condition to detect a password modification

can I add [var1_email] = [var3_email] to detect also an email modification ?

How can I use one or the other and not both conditions in the auto action ?

Thanks in advance

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

Moderators: beatnantkrileon
Powered by Kunena Forum