Which hook to use to catch Admin manually changing an invoice

Discussion in 'Integration' started by edusites, Oct 24, 2014.

  1. edusites

    edusites aMember Pro Customer

    Joined:
    Aug 9, 2009
    Messages:
    47
    I'm trying to add a custom function that is triggered when an admin user sets a User Invoice as 'Manually Paid', which hook can I use to do this?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    Do you mean after payment insert? You can use hook
    Code:
    Am_Event::PAYMENT_AFTER_INSERT
  3. edusites

    edusites aMember Pro Customer

    Joined:
    Aug 9, 2009
    Messages:
    47
    I tried that, the problem I have is that I need the expression engine user id to use in this function, but it is not available at this point as the user hasn't been added to EE.

    Can you tell me when does the EE member entry get created for new users? And what hook can I use that occurs after this has happened?
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    All integration plugins uses the following hook to sync users with 3rd part databases.
    PHP:
    Am_Event::SUBSCRIPTION_CHANGED
    You can use same hook in site.php
  5. edusites

    edusites aMember Pro Customer

    Joined:
    Aug 9, 2009
    Messages:
    47
    Thanks! Can you tell me how I access the product id in the event data please?

    I use $event->getProduct()->getProductID() in another event, but that's not available in this event.
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    This event triggered once for multiple changes. So I recommend you to check current user active products the following way
    PHP:
    $event->getUser()->getActiveProductIds();

Share This Page