Hook doesn't work

Hey there,

I am working on to create a pre-user registration hook to filter users by their IP address. I want to check users’ IP before get database information. So that I choose to create a hook instead of rules. However, It seems like it doesn’t work. at first, I thought it could be a code mistake. but even if I print a message through console.log, it doesn’t show anything. I used the code below.

module.exports = function (user, context, cb) {
  user.hello = 'world';
  console.log('===> set "hello" for ' + user.hello);
  cb(null, user, context);
}; 

I checked the logs with real-time webtask logs, it shows just as below.

11:45:47 AM:Connected
11:48:35 AM:new webtask request
11:48:35 AM: finished webtask request

I have also tried with Client Credentials Exchange hook, and Post User Registration hook, it gives me the same result. I have double checked the hooks are active. I have no idea how to make it work. Can anybody help me with this?

Can you confirm that this is really the pre-user registeration hook and not post-user registration.
Also, it is a user from a database connection, not a social connection (Facebook, Google), right? Cause these don’t trigger the hook.
And the hook is also enabled, I assume.

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!