Joomla附属注册插件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Joomla附属注册插件相关的知识,希望对你有一定的参考价值。
<?php // Check to ensure this file is included in Joomla! jimport('joomla.plugin.plugin'); class plgUserPap4 extends JPlugin { function plgUserPap4(& $subject, $config) { parent::__construct($subject, $config); } /** * Example store user method * Method is called after user data is stored in the database */ function onAfterStoreUser($user, $isnew, $succes, $msg) //function onBeforeStoreUser($user, $isnew) { global $mainframe; // convert the user parameters passed to the event // to a format the external application $args['username'] = $user['username']; $args['email'] = $user['email']; $args['fullname'] = $user['name']; $args['password'] = $user['password_clear']; $args['parentuserid'] = $user['parentuserid']; //foreach($user as $k=>$v) { // echo "$k = $v<br>"; //} if ($isnew) { // Call a function in the external app to create the user // ThirdPartyApp::createUser($user['id'], $args); require("PapApi.class.php"); // load plugin params info $plugin =& JPluginHelper::getPlugin('user', 'pap4'); $pluginParams = new JParameter( $plugin->params ); $pap4Url = $pluginParams->get( 'pap4_url', 1 ); $pap4Username = $pluginParams->get( 'pap4_username', 1 ); $pap4Pwd = $pluginParams->get( 'pap4_password', 1 ); try { // login to API $session = new Gpf_Api_Session($pap4Url); if(!$session->login($pap4Username, $pap4Pwd)) { echo ("Cannot login. Message: ".$session->getMessage()); return; } $clickTracker = new Pap_Api_ClickTracker($session); try { $clickTracker->track(); } catch (Exception $e) { } if ($clickTracker->getAffiliate() != null) { $args['parentuserid'] = $clickTracker->getAffiliate()->getValue('userid'); } // create new affiliate $affiliate = new Pap_Api_Affiliate($session); $affiliate->setUsername($args['email']); $affiliate->setPassword($args['password']); $affiliate->setFirstname('Joomla'); $affiliate->setLastname($args['fullname']); $affiliate->setParentUserId($args['parentuserid']); if(!$affiliate->add()) { echo("Cannot add record: ".$affiliate->getMessage()); return; } else { echo("Affiliate successfuly added"); } } catch(Exception $e) { echo("PAP4 API call error: ".$e->getMessage()); return; } } } }
以上是关于Joomla附属注册插件的主要内容,如果未能解决你的问题,请参考以下文章