Hi, i followed the admin-plugin-maker wizard and everything seemed to go well, i could add the plugin and then add the integration via 'protect content' without any issues. However when i manually create a new user i get an error that just says 'The database has encountered a problem, please try again later.' If i remove the plugin i can then create users without any issues. Note that i am using the same database amember is on with a custom table that i want the active user data written to. my plugin data is as follows: Code: class Am_Protect_Actives extends Am_Protect_Databased { const PLUGIN_DATE = '$Date$'; const PLUGIN_REVISION = [EMAIL]'@@VERSION@@'[/EMAIL]; protected $guessTablePattern = "am_custom_actives"; protected $guessFieldsPattern = array( 'user_id','pw', ); protected $groupMode = Am_Protect_Databased::GROUP_NONE; public function afterAddConfigItems(Am_Form_Setup_ProtectDatabased $form) { parent::afterAddConfigItems($form); // additional configuration items for the plugin may be inserted here } public function getPasswordFormat() { return SavedPassTable::PASSWORD_PLAIN; } /** * Return record of customer currently logged-in to the * third-party script, or null if not found or not logged-in * @return Am_Record|null */ public function getLoggedInRecord() { // for single-login must return } public function loginUser(Am_Record $record, $password) { // login user to third-party script } public function logoutUser(User $user) { // logout user from third-party script } public function createTable() { $table = new Am_Protect_Table($this, $this->getDb(), '?_am_custom_actives', 'id'); $table->setFieldsMapping(array( array(Am_Protect_Table::FIELD_ID, 'user_id'), array(Am_Protect_Table::FIELD_PASS, 'pw'), )); return $table; } function getReadme() { return <<<CUT actives README CUT; } }
here is what is in the logs, something missing? no field name? Code: Unknown column '' in 'where clause' at /home/leetspea/public_html/test/cms/library/Am/Record.php line 601(1054) in query: SELECT * FROM am_custom_actives WHERE ``='sdflkjsdf' LIMIT 1
You must specify login field in your plugin. Create field for login in your mysql table, then edit plugin and change this function: PHP: public function createTable() { $table = new Am_Protect_Table($this, $this->getDb(), '?_am_custom_actives', 'id'); $table->setFieldsMapping(array( array(Am_Protect_Table::FIELD_ID, 'user_id'), array(Am_Protect_Table::FIELD_PASS, 'pw'), array(Am_Protect_Table::FIELD_LOGIN, 'login'), )); return $table; }
another related question, when i remove someones access by deleting the invoice or access they are not being removed from the integration database table, should this occur? if not, how do i make it happen? The manual for custom integrations says "When their subscription expires, users will be automatically disabled or (if configured) removed from third-party database. " how do i configure the remove option?
Add this to plugin: PHP: function onSubscriptionDeleted(Am_Event_SubscriptionDeleted $event){ $found = $this->getTable()->findByAmember($event->getUser()); if (!$found || !$this->canRemove($found)) return; if($this->calculateGroups($event->getUser())) return; if ($this->getConfig('remove_users')) { $this->_table->removeRecord($found); } elseif (!$this->isBanned($found)) { $this->_table->disableRecord($found, $this->calculateGroups(null, true)); }}
Alex, Hello...I have been trying to get in touch with you. I need help with a custom plugin for a payment system and integrate it with amember. I do not have the knowledge to create this on my own. Can you help? I have a help ticket number, but it disapeared #QXR-77923-674 John Slater flyinjs@epix.net
Thanks again Alex, works like a charm, next problem though, i setup a single group plugin and it works fine, puts the group_id into my group_id on the integrated table, although, when i setup multi groups its not passing the group_id in, the field is set to varchar(10) and everything else goes in, just not the group_id. latest plugin below: Code: <?php class Am_Protect_Tsactives extends Am_Protect_Databased { const PLUGIN_DATE = '$Date$'; const PLUGIN_REVISION = [EMAIL]'@@VERSION@@'[/EMAIL]; protected $guessTablePattern = "am_custom_actives"; protected $guessFieldsPattern = array( 'user_id','server_id','pw','login','email','name_f', ); protected $groupMode = Am_Protect_Databased::GROUP_MULTI; public function afterAddConfigItems(Am_Form_Setup_ProtectDatabased $form) { parent::afterAddConfigItems($form); // additional configuration items for the plugin may be inserted here } public function getPasswordFormat() { return SavedPassTable::PASSWORD_MD5; } /** * Return record of customer currently logged-in to the * third-party script, or null if not found or not logged-in * @return Am_Record|null */ public function getLoggedInRecord() { // for single-login must return } public function loginUser(Am_Record $record, $password) { // login user to third-party script } public function logoutUser(User $user) { // logout user from third-party script } public function createTable() { $table = new Am_Protect_Table($this, $this->getDb(), '?_am_custom_actives', 'id'); $table->setFieldsMapping(array( array(Am_Protect_Table::FIELD_ID, 'user_id'), array(Am_Protect_Table::FIELD_GROUP_ID, 'server_id'), array(Am_Protect_Table::FIELD_PASS, 'pw'), array(Am_Protect_Table::FIELD_LOGIN, 'login'), array(Am_Protect_Table::FIELD_EMAIL, 'email'), array(Am_Protect_Table::FIELD_NAME_F, 'name_f'), )); return $table; } public function getAvailableUserGroupsSql() { return "SELECT server_id as id, server_name as title, NULL as is_banned, #must be customized NULL as is_admin # must be customized FROM ?_am_custom_servers"; } function getReadme() { return <<<CUT tsactives README CUT; } }
John, Please contact me at alexander@cgi-central.net if you still haven't received reply from helpdesk.
leetspeak, Default usage of Am_Protect_Databased::GROUP_MULTI is when you have separate table where groups are stored. In this situation you should describe that table using Am_Protect_Table::setFieldsMapping function. If you store multiple groups in one fileld, you must override Am_Protect_Table::setGroups and Am_Protect_Table::getGroups above two methods are used to save groups and to get groups from user record. First remove GROUP_ID field defenition from your createTable method. At the bottom of your plugin create new class: PHP: class Am_Protect_Table_Tsactives extends Am_Protect_Table{ function setGroups(Am_Record $record, $groups){ // Let's say you will separate groups by comma, $record->updateQuick('server_id', join(',', $groups)); } function getGroups($record){ return split(',', $record->server_id); }} then in createTable method change class name from Am_Protect_Table to Am_Protect_Table_Tsactives