Cancel vote when user is deleted Is there any way to cancel user votes (if there are any) when I completely delete a user account?
Thanks kiamlaluno for the first guide. I'm really lost about writing even a mini-module.

Here's the code for what i was needing:

// Cancel / subtract user vote from 'poll_choice' table, when user account is cancelled.
// The code (db_update) which subtract users vote is a copy from poll.module
function MODULE_NAME_user_delete($account) {
    $uid = $account-&gt;uid;
    $votes_id = db_query("SELECT chid FROM {poll_vote} WHERE uid = :account_id", array(':account_id' =&gt; $uid))-&gt;fetchAll();
    foreach ($votes_id as $vote_id) {
        db_update('poll_choice')
        -&gt;expression('chvotes', 'chvotes - 1')
        -&gt;condition('chid', $vote_id-&gt;chid)
        -&gt;execute();
    }
}


This is for MODULE_NAME.install. We need it to make sure poll_vote table is not update before this module function is executed.

function MODULE_NAME_install(){
  db_update('system')
    -&gt;fields(array('weight' =&gt; -1))
    -&gt;condition('name', 'MODULE_NAME', '=')
    -&gt;execute();
}