Help & KnowledgeBase

Hook into the system

Hooking into the system allows you to add more features and this can be done from your plugin loader.php file as you are going to see in the following examples

And also we have the list of available hooks that you can hook into with the register_hook() function

crea8socialPRO makes use of a hook function to attach multiple callbacks to an event and trigger those callbacks when that event is called.
A typical example is used below.




                register_hook('sum-up',NULL,function($values){  return array_merge($values,[3,4,5,6,7,8]); });
                register_hook('sum-up',NULL,function($values){  return array_sum($values); });
                $result = fire_hook('sum-up',['1','2','3','4','5']);
                print_r( $result );


The function is used by passing event to be fired as the register_hook() method and attaching as many events as possible.Then finally the value is passed after all events has being queued, into the  fire_hook()  method.values to be manipulated is passed to the function, then the event is automatically fired up.

Cool isn't it? :)


This is just a bascic example, it can be used for more advance actions.