Can't seem to get the registerFunction to work

12 years 4 months ago - 12 years 4 months ago #185641 by sfraise
I'm trying to put together a simple plugin that will add a connection to a user automatically when someone registers.

I can't post in the member categories until I can get my membership renewed but thought it was worth a shot posting here anyway.

Here's my plugin code, it installs fine, it just doesn't work lol. I've tried both onAfterUserRegistrationSave and onUserActive, let me know if anything stands out:
$_PLUGINS->registerFunction( 'onUserActive', 'addConnection', 'getautoConnectTab' );

class getautoConnectTab extends cbTabHandler {
	/**
	 * Construnctor
	 */
	function getautoConnectTab() {
		$this->cbTabHandler();
	}
	
	/**
	* Makes the connection
	*/
	function addConnection($user) {
		global $_CB_database,$_CB_framework;

		$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
?>

Please Log in to join the conversation.

12 years 4 months ago #186071 by sfraise
I can hear crickets chirping in this post it's so quiet lol.

I can verify the plugin is active by doing a simple echo, but is there anyway to verify what's going on with the actual function? I did try sticking an alert in there but since this is set to fire on activation or registration (which ever way I go) and not on a page load or anything like that I'm not sure how to test that function.

It seems like such a simple thing, someone has to have an idea here.

Please Log in to join the conversation.

12 years 4 months ago #186090 by nant

Please Log in to join the conversation.

12 years 4 months ago #186114 by sfraise
Thanks nant, I thought I had that plugin laying around on my computer somewhere but can't seem to find it. I'm waiting on the company credit card so I can renew my membership and grab it, hopefully I can do it today still.

Please Log in to join the conversation.

12 years 4 months ago #186599 by sfraise
I've picked through a few plugins using the onAfterRegistration function and from looking at those it seems like what I have should work, I can add a simple echo to show the plugin is installed and published ok, I just can't get this function to fire.

Here's what I have at the moment, maybe someone can spot something wrong:
/** ensure this file is being included by a parent file */
removed for posting in form purposes

global $_CB_framework, $_PLUGINS;
$_PLUGINS->registerFunction( 'onAfterUserRegistration',			'addConnection',			'getAutoConnectTab' );


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>';
	}
} // end of autoConnectTab class

Please Log in to join the conversation.

12 years 4 months ago #186683 by sfraise
Just renewed my membership finally so going to move this over to the pro forum.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.238 seconds

Facebook Twitter LinkedIn