help convertin 3.8 plugin to latest

Discussion in 'Customization & add-ons' started by misulicus, Mar 26, 2012.

  1. misulicus

    misulicus New Member

    Joined:
    Feb 20, 2012
    Messages:
    7
    Ok so its way more harder for me to figure this out.
    For version 3.8 it was pretty easy. All i needed was:
    setup_plugin_hook('subscription_added'
    setup_plugin_hook('subscription_deleted',
    setup_plugin_hook('subscription_removed',

    I made my 2 php files with config and the actual plugin that did what i wanted when those actions happened in amember.
    On the new version i dont know even where to start recrating my plugin
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    create file amember/application/default/plugins/misc/misulicus.php

    PHP:
    class Am_Plugin_Misculicus extends Am_Plugin
    {
        function 
    onSubscriptionAdded(Am_Event_SubscriptionAdded $event)
       {
              
    $product $event->getProduct();
              
    $user $event->getUser();
              
    $this->getDi()->errorLogTable->log(print_r($product->toArray()) . '-' print_r($user->toArray()));
       }

        function 
    onSubscriptionDeleted(Am_Event_SubscriptionDeleted $event)
       {
       }

       function 
    onSubscriptionRemoved(Am_Event_SubscriptionRemoved $event)
       {
       }
    }
    http://www.amember.com/docs/Main_Page
    Programming API
  3. misulicus

    misulicus New Member

    Joined:
    Feb 20, 2012
    Messages:
    7
    Ok thanks for that
    Couple mor q:
    Am_Event_SubscriptionAdded means user just Paid for a subscription right ? Doesent matter that he had one before or not. It means he just paid for one. Does it applyu for a product that has price 0 ?

    Am_Event_SubscriptionDeleted means the subscription user had expired ? i mean he paid for 2 days for example and when the 2 days passed its removed ?

    Same for the SubscriptionRemoved ?
    Confused wich one does what. ALso is there one wich gets called when admin removes product or adds one to a user from admin side ?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    subscriptionAdded event will be fired when user gets subscription to a product which he didn't have before.(Price does not matter here)
    So if user already had an active subscription to the same product, event will not be fired.
    subscriptionDeleted - again will be fired when user's subscription to any product expires and user don't have active subscriptions to the same product.
    subscriptionRemoved - when user is deleted from the system.

Share This Page