Make a treatment before the action of the form

That’s because you’re using a post action which sends the user to another website. The template_redirect never runs because the user isn’t on your site any more. You’ll need to keep them on the site, register the new user then send them to the gateway with the post data.