Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jazzdrive3 on
I'd like to hook into the poll vote process, and then insert into the Activity module to show that a user voted for a certain poll.
But the default poll module doesn't have any special hooks, that I'm aware of. Please correct me if I'm wrong.
I might be able to redirect the form on submit to a menu_callback, but that seems a bit hacky.
Any other options?
Thanks!
Comments
Use hook_form_FORM_ID_alter to add a custom submit handler
The Leprechaun says you can use hook_form_FORM_ID_alter to add a submit handler. See http://api.drupal.org/api/function/hook_form_FORM_ID_alter/6. Get the form id for the poll form and create the appropriate function name. In the appropriate function:
In your function 'custom_code_handler()', you'd perform all you custom logic.
Just a note
To add a custom submit handler on poll vote, you must do it this way:
Adding it to the top level (not under 'vote'),
will not work.
This link was very helpful: Overriding The Poll Module In Drupal 6