Hi everybody
I have the same problem : on activation, I would like to insert data in a second database with the registration informations (it's for a game : the user must register in the forum to create a character)
I tried to use this tutorial (http://wiki.simplemachines.org/smf/Add_a_custom_action_using_integration_hooks), but I can't seem to make it work.
I try to make my action function simpler and simpler, but still can't get it to run : no error printed, but no action done
here is the content of my files
<?php
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
add_integration_function('integrate_pre_include', '$sourcedir/Subs-AddPlayerToVdd.php',TRUE);
add_integration_function('integrate_activate', 'AddPlayerToVdd_add_hook',TRUE);
?>
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function AddPlayerToVdd_add_hook(&$actionArray) {
$actionArray['AddPlayerToVdd'] = array('AddPlayerToVdd.php', 'AddPlayertoVdd');
}
?>
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function AddPlayertoVdd(){
die('IT WORKS!');
}
?>
I have the following data in my smf_settings table :
variable | value |
integrate_pre_include | $sourcedir/Subs-AddPlayerToVdd.php |
integrate_activate | AddPlayerToVdd_add_hook |
I would be very grateful if someone could give me a hint about what I did wrong
Thanks
I went ahead and split your topic...
Not sure what, if anything you're doing wrong but try this method instead:
http://www.simplemachines.org/community/index.php?topic=453008.0
There's some instructions in that thread but basically:
Download the hooks file
Comment out all the hooks besides the registration one you want to use
Write your db inserts into the registration function
Upload it
Include it (require_once) in your main SMF index.php file
I have tested and used it and it works :)
Quote from: Labradoodle-360 on May 04, 2012, 11:49:31 AM
I went ahead and split your topic...
Thanks, I wasn't sure if I should create a new topic or not.
QuoteNot sure what, if anything you're doing wrong but try this method instead:
http://www.simplemachines.org/community/index.php?topic=453008.0
I had read this post, but I was under the impression that SMF2 hooks allowed to do what I wanted without adding a new file.
Well, if I can't get anything else to work, I thing I will try his method
thanks
The hooks just indicate what function to call. The function must of course already be loaded in order for that to work...
what I had understood was :
add_integration_function('integrate_pre_include', '$sourcedir/Subs-AddPlayerToVdd.php',TRUE);
this one loads the Subs at the begining
in $sourcedir/Subs-AddPlayerToVdd.php, I have this function AddPlayerToVdd_add_hook which adds
$actionArray['AddPlayerToVdd'] = array('AddPlayerToVdd.php', 'AddPlayertoVdd')
and in AddPlayerToVdd.php, I have the AddPlayertoVdd function which should print something
add_integration_function('integrate_activate', 'AddPlayerToVdd_add_hook',TRUE);
I thing this one should be called when a user or an admin activates his account. since the $sourcedir/Subs-AddPlayerToVdd.php file was included at the begining, I can't find where the hole in the chain is
OK, so the first one does load your file. But you don't need to touch the actionArray, that's just the list of actions for handling with index.php?action= items. That's only useful if you're calling index.php?action=AddPlayerToVdd in your case - which you're not.
Instead your function that actually carries out registration should be the one named AddPlayerToVdd_add_hook. Check what integrate_activate sends so that your function receives it.
Quote from: Hetasser on May 05, 2012, 11:30:31 AM
Quote from: Labradoodle-360 on May 04, 2012, 11:49:31 AM
I went ahead and split your topic...
Thanks, I wasn't sure if I should create a new topic or not.
QuoteNot sure what, if anything you're doing wrong but try this method instead:
http://www.simplemachines.org/community/index.php?topic=453008.0
I had read this post, but I was under the impression that SMF2 hooks allowed to do what I wanted without adding a new file.
Well, if I can't get anything else to work, I thing I will try his method
thanks
So where are you writing your functions? You have to call a new file somewhere... and where are you defining what function your hooks should call?
IMHO it's better to just keep it all in one central location, hence the hooks file above. That way when you need to mess with the hooks you know exactly where to go :)