MODX Community

Login.Register and Hooks

Hi all,

I’ve got two questions both having to do with each other.

  1. How do you get the ID of a user that was just created in a hook (to do some PDO stuff with).
    and 2) is it possible to redirect using a hook and not Login’s own redirect hook? There are some variables I want to use to determine where the user ends up.

Thanks.

see https://docs.modx.com/current/en/extras/login/login.tutorials/using-pre-and-post-hooks
there is

$user = $hook->getValue('register.user');

and you can use $modx->sendRedirect in your hook

https://docs.modx.com/current/en/extending-modx/modx-class/reference/modx.sendredirect