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 #237125 by activha
Hello
Using code auto action, I would like to edit a field using afteruserregistration trigger .

I tried
$referer = $affiliate->getUserid(); //which gets the affiliate ID from my PAP installation
$user = CBuser::getMyUserDataInstance();
$user->storeDatabaseValue( 'cb_refid', $referer );

but this does not update the cb_refid field.

The user is of course not logged in as it comes just after the registration

What do I miss ?
Last edit: 10 years 11 months ago by krileon.

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 #237173 by krileon
That user object API call grabs "My User". As they are not logged in one does not exist. You need to grab their user object using the below.

$user = CBuser::getUserDataInstance( '[user_id]' );


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.
The following user(s) said Thank You: activha

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 #237212 by activha

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 #237255 by activha
Hello Kyle

I am reopening this post as we got a problem with the trigger and cb paid subscriptions.

We use onAfterUserRegistration trigger and it works great to copy the field for users who do not go to a payment process through cbpaidsubscription.

However when users are redirected to a payment gateway the field is not copied and left blank.

I use :
// create new affiliate
$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUsername($args);
$affiliate->setPassword($args);
$affiliate->setFirstname($args);
$affiliate->setLastname($args);
$affiliate->setRefid($args);
$affiliate->setParentUserId($args);
if(!$affiliate->add()) {
die("Erreur message: ".$affiliate->getMessage());
}
else {
// echo("Affiliate successfully added");
$affiliate->getUserid();
$user = CBuser::getUserDataInstance( '[user_id]' );
$user->cb_refid = $affiliate->getUserid();

This behavior occurs with any payment gateway. I have noticed that the user is not activated by default as long as the payment is not made. May this be the cause ?

I tried onstartsaveuserregistration but of course this triggers too early and the data are not sent correctly to PAP for registration.

Does onAfterUserRegistration fires even if the user is not yet activated ? can we use another trigger ?

Can you help on this ? (we would not like to activate paying users by default before that payments are made)

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 - 10 years 11 months ago #237274 by krileon

Does onAfterUserRegistration fires even if the user is not yet activated ?

Yes, it fires as it implies; after registration. No matter the circumstances.

can we use another trigger ?

Yes, the below trigger fires only when the user is 100% active.

onUserActive

But this doesn't help if you need the fields value before than (like during CBSubs).


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 11 months ago by krileon.

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 - 10 years 11 months ago #237287 by activha

Does onAfterUserRegistration fires even if the user is not yet activated ?
Yes, it fires as it implies; after registration. No matter the circumstances.


Well in this case it should fire also if the user is not active and cbsubs payment not done ?
this is not the case though.

Do you have a trigger to solve this or a way to write the field before cbsubs asks for payment ?

How does onBeforeUserActive fire for example ? is this after onAfterUserRegistration ?
Last edit: 10 years 11 months ago by activha.

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

Moderators: beatnantkrileon
Powered by Kunena Forum