Is there a guide anywhere for writing plugins for aMember v4? I need to integrate my CMS but am not sure where to start. Thanks.
@igpman: There are a few plugins that ship with the aMember default installation that you can to for reference (Facebook, Wordpress,etc).. In addition, this URL will walk you through a wizard to create a plugin skeleton for you: http://yourdomain.com/amember/admin-plugin-maker
Thanks, that's a helpful start. It would be nice if there was a more comprehensive documentation, but this should be enough to get by.
I used this to create a skeleton, though the skeleton caused fatal errors which I have fixed and reported in the v4 bugtracker. I get the impression that out of the box this should be able to add users to my third-party database. The comments in the skeleton file say the first step is to test if adding users to the third-party database works, which it doesn't. I've looked in the existing plugin files and their contents seem very similar. Everything is configured correctly as far as I can see but adding users doesn't work, and if I attempt a database rebuild it produces this error: Code: Rebuilding Mycms Db... An internal error happened in the script, please contact webmaster for details. Please contact webmaster: ****@*******.com. Incorrect response received. Stopped! The aMember error log states: Am_Protect_Table->getGroups() is not implemented Code: Exception Am_Exception_NotImplemented Am_Protect_Table->getGroups [ library\Am\Protect\Databased.php : 548 ] Am_Protect_Databased->isAdmin [ library\Am\Protect\Databased.php : 568 ] Am_Protect_Databased->canUpdate [ library\Am\Protect\Databased.php : 687 ] Am_Protect_Databased->batchProcess call_user_func_array [ library\Am\App.php : 1772 ] Am_BatchProcessor->run [ library\Am\Protect\Databased.php : 664 ] Am_Protect_Databased->onRebuild call_user_func [ application\default\controllers\AdminRebuildController.php : 227 ] AdminRebuildController->doAction [ library\Am\Controller.php : 139 ] Am_Controller->_runAction [ library\Am\Controller.php : 116 ] Am_Controller->dispatch [ library\Zend\Controller\Dispatcher\Standard.php : 295 ] Zend_Controller_Dispatcher_Standard->dispatch [ library\Zend\Controller\Front.php : 954 ] Zend_Controller_Front->dispatch [ library\Am\App.php : 1329 ] Am_App->run [ index.php : 41 ] Any idea what's wrong?
Thanks. I have put it on pastebin: http://pastebin.com/uj0MZqDQ I'm sure I have the database configured correctly. The plugin even detects my user groups just fine and I can select the default group for new users etc. EDIT: If you want to see the structure of my user table and the field types I can PM it to you.
The paste will expire soon, so I have put it up for another day: http://pastebin.com/5x2fjYB5 Great job on the new aMember.com btw.
You have choosed group mgmt mode as protected $groupMode = Am_Protect_Databased::GROUP_SINGLE; but table definition does not define field where group_id is set. Quick example: say the third-party script has the following structure: groups table idtitlesample for records:1 Registered Member2 Paid Customer3 Administrator............... users table idusernamepassword......group_id - refers to 'id' field of 'groups' table....... In this case, you must add to your pastebin after line 71: PHP: array(Am_Protect_Table::FIELD_GROUP_ID, 'group_id'), then aMember knows where to fetch group id for user record, and exception will not be thrown.
Thanks. That stopped the error from showing up. Unfortunately it still won't add users to the third-party database when they are added in aMember though. The same is true of trying a database rebuild for the plugin. Am I missing something? Here is the latest code: http://pastebin.com/9PxR0K4F I made sure to also add group_id to the $guessFieldsPattern array. In case you're wondering, that actually is the name of my user group field, coincidentally.
I wonder, did you setup integration between aMember and third-party script? aMember CP -> Protect Content -> Integrations ? If integration was not enabled for your plugin(if you didn't assign aMember products to groups in your third-party script) aMember will not create users in third-party script.
You have to configure integration at aMember CP -> Manage Content -> Integrations Users will be added to your helpdesk once they complete payment (or you add "Access" record to user manually on "Invoices" screen)
I searched for "Manage Content" in the ACP and couldn't find it. But I have already set up and enabled the plugin since the first post. I will explain how to avoid any confusion: I did this in Configuration -> Setup/Configuration -> Plugins, where I added my plugin to list of "Integration Plugins" and clicked save. Then my plugin appeared as a tab button at the top, so I clicked it and configured the database connection and table prefix etc. I know this worked because under "Mycms Integration Settings" on the plugin configuration I am able to select user groups from my tables in Mycms, which demonstrates the link was successful. The settings are saved also, and remain there every time I check them again. The next step in the documentation of the plugin says I should be able to create users and they will be added to the third-party tables. Yet when I add a user or attempt to Rebuild the database in aMember, the user is not added to the Mycms user table.
Thanks, that solved it. I don't remember having to do that in v3 when I made a plugin. Well, now I can get on with integrating the login etc. Thanks again.
In v3 that setting was in different place, in product config. (amember CP -> manage products -> Edit Product)