Welcome Guest, Not a member yet? Register   Sign In
Examples of Calling Hooks Functions?
#1

[eluser]Vik[/eluser]
I've added hooks for Simple Machines Forums to my CI installation, using code provided on this forum by DanFreak. Here's the hooks.php part of that code:

Code:
$hook['post_controller_constructor'] = array(
                                'class'    => '',
                                'function' => 'load_ssi_smf',
                                'filename' => 'ssi.php',
                                'filepath' => 'hooks'
                                );

My question is, how do I call a function from ssi.php? For example, I've tried:
Code:
$UserIsLoggedIn = smf_authenticateUser();

...and found that this generates an “undefined function” error.

What is the correct way to do this?

Thanks very much in advance for any info.
#2

[eluser]Majd Taby[/eluser]
you can tell php that the hooks class is in your helpers folder, then (auto)load it.
#3

[eluser]Vik[/eluser]
I think I may have done that, because I've done all the things DanFreak describes:

[quote author="danfreak" date="1175743689"]
application/config.php
Code:
$config['enable_hooks'] = TRUE;

application/config/hooks.php
Code:
$hook['post_controller_constructor'] = array(
                                'class'    => '',
                                'function' => 'load_ssi_smf',
                                'filename' => 'ssi.php',
                                'filepath' => 'hooks'
                                );

application/hooks/ssi.php

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
function load_ssi_smf()
{
        require_once('smf/SSI.php'); //change the directory to suit your needs
}
?>
[/quote]

Once you do all that, how do you call one of the new functions? An example would be very helpful.




Theme © iAndrew 2016 - Forum software by © MyBB