Skip to Content Skip to Menu

Can't seem to get the registerFunction to work

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 10 months ago - 12 years 10 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:
Code:
$_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 ?>
Last edit: 12 years 10 months ago by sfraise.

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 10 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 or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
12 years 10 months ago #186090 by nant

Please Log in or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 10 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 or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 10 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:
Code:
/** 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 or Create an account to join the conversation.

  • sfraise
  • sfraise
  • OFFLINE
  • Posts: 96
  • Thanks: 14
  • Karma: 4
12 years 10 months ago #186683 by sfraise
Just renewed my membership finally so going to move this over to the pro forum.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum