I have been trying to communicate with someone over the support system about this but I don't think that I'm being understood properly so I'm posting here in the hopes that someone has managed to get subscription_rebuild working in their custom amember plugin.. this is my code Code: setup_plugin_hook('subscription_rebuild','ab_db_sync'); function ab_db_sync($memberlist){ die(print_r($memberlist)); } it is in my abvog_plugin.inc.php file which is located in /amember/plugins/protect/abvog_plugin/ folder the plugin has been activated in amember admin. The plugin file also has other hooks and functions that are functioning (eg. subscription_updated) so I know the plugin file is active and being included. problem The rebuild DB function is supposed to fire the function that is attached to this hook but it doesn't. No matter where I put the setup_plugin_hook it wont work. I tried it in the plugin file.inc.php or the config.inc.php or even in site.inc.php but it never ever runs (or dies as it should) when I click on rebuild DB tests to test if the plugin file gets included, I put a deliberate error in the code and even declared the function twice but even that wont cause an error when I try to rebuild DB!! this tells me that the rebuild DB function is not calling the hook or even including the plugin file OR config.inc.php file I tried explaining this to support but I don't think they understand what I'm trying to say. Please... has ANYONE got this plugin hook to work ? I can see that this hook and function has been updated in a recent update, could it be that it no longer works or has been left out entirely? I would really like to get this feature working,
Take a look in the manual here: http://manual.amember.com/Creating_New_Integration_Plugins#subscription_rebuild.28.26.24members.29 Example: Code: setup_plugin_hook('subscription_rebuild','ab_db_sync'); function ab_db_sync(&$users) { global $db; foreach( $users as $login => $rec ) { $m = $db->users_find_by_string( $login, 'login', 1 ); $m = $m[ 0 ]; if( $m[ 'login' ] == $login ) { $pays = $db->get_user_active_payments( $m['member_id'], date( 'Y-m-d' ) ); foreach( $pays as $p ) { yourfunctiontoaddusers( $p['payment_id'] ); } } } }
The problem is in your tests. In last version aMember CP -> Rebuild DB handled through ajax calls, so you just don't see error messages. Change die(print_r($memberlist)); in your function to global $db; $db->log_error("Rebuild running"); a and you will see calls in aMember CP -> Error/Debug log
beautiful. precise answer and exactly correct. thanks Alexander. problem solved. It would be very helpful to add that to the wiki page here http://manual.amember.com/Creating_New_Integration_Plugins#subscription_rebuild.28.26.24members.29 thanks again. I can now continue with the project! Andy
I agree, now I see it's AJAX (now it's obvious!) I can see the JSON data being returned shows an error happens before it gets to the "msg":"success" data. I guess I should have been testing with firefox and firebug open and I would have seen it myself :-z thanks for being on the case! btw.. did you see this post about other minor changes that could be updated to make it play nice with wordpress?