when someone's subscription becomes active when someone's subscription expires when user changes password when user unsubscribe (if there is such thing) Thanks Richard
Richard: 1. Am_Event::SUBSCRIPTION_ADDED 2. Am_Event::SUBSCRIPTION_DELETED 3. Am_Event::SET_PASSWORD 4. Am_Event::USER_UNSUBSCRIBED_CHANGED
Thank you. I also found these events: Subscription_Changed - meaning the user may still be subscribed but products change (add and/or removal) Subscription_Updated - what is that? Subscription_Removed - this is the same as subscription_deleted? Or it is about just partial removing of products (if user remove the product I watch it means I need to treat it like subscription_delete?
1. Will be fired in addition to subscription_added and subscription_updated hooks. It is fires whenever user's subscriptions are changed. 2. This hook is deprecated. Use Am_Event::USER_AFTER_UPDATE instead. Will be fired when user change his profile. 3. This hook will be executed when user is removed from system.
OK. The names are little tricky so I insist a bit. Let say one user has subscribed to 2 products and unsubscribe from only one. Then the SUBSCRIPTION_DELETED fires but not SUBSCRIPTION_REMOVED, is that right?
Yes right. SUBSCRIPTION_REMOVED will be fired if user deleted from system. SUBSCRIPTION_DElETED if user's subscription expires, but account is still in the system.
thanks. is there an event when the user is registering for the first time (and he is valid and saved in aMember database)?
Use Am_Event::SIGNUP_USER_ADDED Executed when User (or affiliate) record is added after submitting signup form - before payment
Hi, I just bought the subusers module since I figured out I need to sell access (and invoice) at per company in some cases. At this stage I need to update my integration to use GROUPS and I need to detect additionaly these events: - when a reseller subscription is activated - when a reseller activates a subuser Can you point me to the right events here?
Or perhaps I can use the same events and just test if user is reseller and if user is subuser (and who is the parent user). In that case what are the tests to do?
Just use the same hooks. To test User object is it is a reseller use something like this: PHP: function onAccessAfterInsert($event){ $access = $event->getAccess(); $user = $access->getUser(); if (! $user->data()->get('subusers_count')) return; /// the following code will be executed for resellers only try { $invoice = $access->getInvoice(); } catch (Exception $e) { return; // this access record is not tied to invoice - manually added } // now you have User $user and Invoice $invoice - you can do whatever you need this full info} For second task it is better to use Am_Event::USER_AFTER_INSERT hook. To test if User is a "subuser" add to your plugin the following method: PHP: function onUserAfterInsert($event){ $user = $event->getUser(); if ($user->subusers_parent_id) { // this user belongs to a reseller // lets load reseller record $resellerUser = Am_Di::getInstance()->userTable->load($user->subusers_parent_id, false); if (!$resellerUser) return; // not loaded??? deleted?? }}
$user->data()->get('subusers_count') will give me the actual number of user the reseller defined or the number he is able to define? I am afraid I need to know if he is a reseller even before he starts to define new users. Is that possible?
Subusers has more complex structure. Do PHP: $this->getDi()->errorLogTable->log( "subusers_count: {$user->login} " . print_r($user->data()->get('subusers_count']), true)); to review it... It will be set before reseller starts to define new users. It is only important to check that this hook is executed after the hook of subusers module that defines the "subusers_count" var. Please run such a test: add new user to aMember, go to "Payments" tab and add access to "reseller" product. THen look at aMember CP -> Error Log. If it is empty, we can define new hook in subusers module..
In fact I solved my problem like this: I am not anymore interested if the user is reseller until he register the first subuser. When first subuser subscription is activated I check who is the reseller and I create a group it it does not already exists. Then I associate the reseller and the current user with that group.