Skip to content

Instantly share code, notes, and snippets.

@benedmunds
Created May 22, 2012 13:45
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benedmunds/657de89b26decda2b2fa to your computer and use it in GitHub Desktop.
Save benedmunds/657de89b26decda2b2fa to your computer and use it in GitHub Desktop.
CodeIgniter Ion Auth - set_hooks example
//this would probably be in a library or model
class activity
{
function add($type)
{
$this->db->insert('activity', array(
'type' => $type,
'datetime' => 'now()',
));
}
}
//set the hook
$this->ion_auth->set_hook('post_register', 'add_meta', 'activity', 'add', array('user_added'));
//other stuff...
//after this is called the hook will be executed automatically
$this->ion_auth->register(...
@rafidcse
Copy link

thanks

@wrabit
Copy link

wrabit commented Nov 11, 2014

Can I have the hooked method in one controller and set_hook() run from another controller?

@babyfaceEasy
Copy link

Is there a way for me to pass data in the present ion-auth function into my own function? i want to hash both the activation code and the id found in the link sent to user's email addresses, in order to activate their account. Then inside the activate (inside ion-auth-model) i want to 'un-hash' it so that ion-auth flow can continue as normal..

@datamweb
Copy link

Hello,@benedmunds
I can run your example. The data in the table is entered correctly.by:
$this->ion_auth->set_hook('post_register', 'add_meta', 'activity', 'add', array('user_added'));
But why does not the following command answer?
$this->ion_auth->set_hook('post_activate', 'add_meta', 'activity', 'add', array('user_added'));
And i reviewed the following. The correct operation is not done.

$this->ion_auth->set_hook(array('post_activate', 'post_activate_successful'), 'add_meta',  'activity', 'add', array('user_added'));
$this->ion_auth->set_hook('post_activate_successful', 'add_meta',  'activity', 'add', array('user_added'));

please guide me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment