So, Im having a hard time reading the poorly structured and half baked documentation on the amember API. Specifically, for events. The examples found here: http://www.amember.com/docs/API/HookManager Are simply for a custom event and do show how to actually hook an existing event and handle it appropriately. Also, the AM_Event_whatever is confusing. If I wanted to hook when a new user signs up and do something with it.. Code: class MyPlugin extends Am_Plugin { function onMyCustomEvent(Am_Event_SubscriptionAdded $event) { [URL='http://www.amember.com/api/Am_Events/Am_Event_UserProduct.html#var$user'][B][COLOR=#336699]Am_Event_UserProduct::$user[/COLOR][/B][/URL]->getEmail(); // Find users email? } } Or is it supposed to be a global hook and we need to check what the event is WITHIN our hook? So far my searching isnt turning up much on this, and the examples are rather poor. In short, I which to hook the events when people newly sign up, when they let their account expire without paying, and when they explicitly close it. Need to access data such as username, email, password, and membership package. Thank you!
http://manual.amember.com/Creating_New_Integration_Plugins Code: setup_plugin_hook('subscription_added', 'MyFunc'); function MyFunc($member_id, $product_id, $member) { If $product_id is our target product, then add $member['email'] to our 3rd party database with an id of $member_id } Is this pseudo code correct? The first documention I found is completely different. Im pretty tired today, but whats with the documentation difference? This one appears to be the usual structure for hooks and how it should be done.
Separate posts so theyre legible. Appears the above may be old? Shame. Code: Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_ADDED, 'MyFunc'); // This passes my functions an AM_EVENT_SubscriptionAdded object function MyFunc(AM_EVENT_SubscriptionAdded $event) { If this is the correct $event->$product->getProductID(), then add user $event->$user->getEmail() to 3rd party database } Is this, freaking correct?
This manual: http://manual.amember.com/Main_Page is for old amember v3. For current amember version here is exact example: PHP: Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_ADDED, 'MyFunc'); function MyFunc(Am_Event_SubscriptionAdded $event) {// Now you can get user and product objects from event: $user = $event->getUser();$product = $event->getProduct();// You can use prinnt_rr($user->toArray()); in order to see object vars; // Now you need to add user to your database. }// Example of hook that will be implemented when user's subscription expires: Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_DELETED, 'MyFunc1'); function MyFunc1(Am_Event_SubscriptionDeleted $event) {// Now you can get user and product objects from event: $user = $event->getUser();$product = $event->getProduct();// You can use prinnt_rr($user->toArray()); in order to see object vars; // Now you need to delete or disable user in your database. }