API Hook error

Discussion in 'Customization & add-ons' started by ranjit, Aug 27, 2014.

  1. ranjit

    ranjit New Member

    Joined:
    Aug 1, 2014
    Messages:
    3
    Hi,
    As you can see in picture , The Update Subscription should work when i change date to a newer date.[​IMG]
    But it didnt work.
    This is how i added subscription . It works when adding new subscription if it wasnt there previously .

    Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_ADDED, 'OnSubscriptionAdded');

    This also works if subscription is expired
    Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_CHANGED, 'OnSubscriptionChanged');


    But when i change subscription date from admin panel of amember it wont recognize
    Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_UPDATED, 'OnSubscriptionUpdated');

    There is one more thing it works, if i use user frontend to add subscription .

    So tell me is there any HOOK available on this call

    Access date changed (expire_date) old value=2014-08-21 new_value=2014-08-30 user_id=26
    [​IMG]

    www.amember.com/docs/API/HookManager
  2. ranjit

    ranjit New Member

    Joined:
    Aug 1, 2014
    Messages:
    3
    Screenshot for better understanding

    Attached Files:

  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    In case of user status is not changed (you just updated expire date but user still active) then these hooks is not triggered.
  4. ranjit

    ranjit New Member

    Joined:
    Aug 1, 2014
    Messages:
    3
    Is there any HOOK that trigger for that action ?
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Unfortunately there is not hook for such case.
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I want to update this thread for someone who face same task.
    You can use event Am_Event::ACCESS_AFTER_UPDATE. It is triggered when access record updated.

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::ACCESS_AFTER_UPDATE, function(Am_Event $e) {
        
    /** @var Access $access */
        
    $access $e->getAccess();
    });

Share This Page