I'm trying to build a simple cb plugin to auto connect a few members onafterregistration but I can't seem to get the function to fire.
The plugin installs fine and is published, I can add a simple echo before the main class and it will output on the profile.
Here's what I have:
Code:
<?php
/**
* Joomla Community Builder User Plugin: plug_autoconnect
* @version $Id$
* @package plug_autoconnect
* @subpackage autoconnect.php
* @author Spencer Fraise
* @copyright (C) Spencer Fraise, www.myrecovery.com
* @license Limited http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @final 1.0
*/
/** ensure this file is being included by a parent file */
--- REMOVED FOR POSTING IN FORUM ---
global $_CB_framework, $_PLUGINS;
$_PLUGINS->registerFunction( 'onAfterUserRegistration', 'addConnection', 'getAutoConnectTab' );
/**
* Basic tab extender. Any plugin that needs to display a tab in the user profile
* needs to have such a class. Also, currently, even plugins that do not display tabs (e.g., auto-welcome plugin)
* need to have such a class if they are to access plugin parameters (see $this->params statement).
*/
class getAutoConnectTab extends cbTabHandler {
/**
* Construnctor
*/
function getAutoConnectTab() {
$this->cbTabHandler();
}
/**
* Test Function
*/
function testAlert( $user ) {
global $_CB_database,$_CB_framework;
echo '<script type="text/javascript">alert("Alert!!"); </script>';
}
/**
* Makes the connection
*/
function addConnection( &$user ) {
global $_CB_framework, $_CB_database;
echo '<script type="text/javascript">alert("Alert!!"); </script>';
$userid = $user->id;
$membersince = date("Y-m-d");
$sql="INSERT INTO #__comprofiler_members (referenceid, memberid, accepted, pending, membersince) VALUES ('340', '$userid', '1', '0', '$membersince')";
$_CB_database->SetQuery($sql);
$sql="INSERT INTO #__comprofiler_members (referenceid, memberid, accepted, pending, membersince) VALUES ('$userid', '340', '1', '0', '$membersince')";
$_CB_database->SetQuery($sql);
return true;
}
} // end of autoConnectTab class
?>
Does anything pop out at you that would prevent this from working?
I've looked through a few other plugins and by looking at them it seems like this should work. I can't even get a simple alert to pop here so I must be trying to call the onAfterUserRegistration wrong or maybe I just misunderstood how this function is supposed to work. I've also tried using the onAfterUserApproval trigger as well with no luck.
I really need to put this thing to bed as soon as possible so any help is greatly appreciated.