Jump to content

Learning how to use hooks


StephenK
 Share

Recommended Posts

Hello,

 

I am still learning ProcessWire.  I am trying to hook a method in ListProConfig.php.  After the processInput method is called I would like to know the user id of the person that called the method, the page name that was involved in changed lister settings, and then get the new settings.

 

I am having problems getting my hook to work.

In the init of my module I have the following code:

wire()->addHook("ListerProConfig::processInput", function($event){

     $this->wire('log')->save('stephen_ext',"Someone called processInput");

});

 

Even though I know that processInput is called I never get anything written to my log.

 

Link to comment
Share on other sites

Hi, I think I found out the problem.  The method processInput in ListerProConfig has a redirect at the end of the method, so it never properly completes. 

I changed the addHook method to addHookBefore and it seems to be working now.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...