Customizing SMF > SMF Coding Discussion
Re: execute another db insert at registration completion
Hetasser:
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, 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
--- Code: (add_action_hook.php) ---<?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);
?>
--- End code ---
--- Code: ("/Sources/Subs-AddPlayerToVdd.php) ---<?php
if (!defined('SMF'))
die('Hacking attempt...');
function AddPlayerToVdd_add_hook(&$actionArray) {
$actionArray['AddPlayerToVdd'] = array('AddPlayerToVdd.php', 'AddPlayertoVdd');
}
?>
--- End code ---
--- Code: ("AddPlayerToVdd.php") ---<?php
if (!defined('SMF'))
die('Hacking attempt...');
function AddPlayertoVdd(){
die('IT WORKS!');
}
?>
--- End code ---
I have the following data in my smf_settings table :
variable valueintegrate_pre_include $sourcedir/Subs-AddPlayerToVdd.phpintegrate_activate AddPlayerToVdd_add_hook
I would be very grateful if someone could give me a hint about what I did wrong
Thanks
Labradoodle-360:
I went ahead and split your topic...
Andre N:
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 :)
Hetasser:
--- Quote from: Labradoodle-360 on May 04, 2012, 11:49:31 AM ---I went ahead and split your topic...
--- End quote ---
Thanks, I wasn't sure if I should create a new topic or not.
--- Quote ---Not sure what, if anything you're doing wrong but try this method instead:
http://www.simplemachines.org/community/index.php?topic=453008.0
--- End quote ---
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
Arantor:
The hooks just indicate what function to call. The function must of course already be loaded in order for that to work...
Navigation
[0] Message Index
[#] Next page
Go to full version