By marcuscavalcanti on
Hi,
I need to overwrite Hooks in my own module.
For example, i need to overwrite user_pass() (user.module) hook in my module, then I wanted to rewrite the signature of the method and it would automatically by Drupal.
Another way would be using some of the specific function of Drupal, like a:
[myown.module]
function user_pass() {
if (exists_hook('user_pass')) {
overwrite_hook('my_callback_function');
}
}
function my_callback_function () {
//my custom implementation of user_pass hook
}
Finally .. the last way would be intercepting a hook, there is this possibility?
Thanks a lot.
- MC
Comments
No, I do think what you ask is possible
First the term 'hook' n Drupal is specific to functions call using module_invoke(). So the function user_pass() is not a hook, just a regular PHP function and I know of no way to override a function.
For the second part, "Finally .. the last way would be intercepting a hook, there is this possibility?", if you mean intercepting/replacing another module hook, no.
Tnks nevets for your
Tnks nevets for your attention :)
So, if I want to change the format of the Drupal reset my password or insert some logic in the method user_pass() can'tI?
It depends on what you mean by "change the format"
Because the function user_pass() simply produces a form, there are ways to alter the form including changing the validation and submit functions. You would need a module that implements the form_alter hook and want to read up on the Forms API
For example, if i change
For example, if i change user_pass_submit() function, to implements my own logic, it is possible?
Indirectly
Indirectly, you need a module that implements the form_alter hook for that form that changes the value of '#submit' for the function to one you provide.