Php Drupal钩子\用户\更新不起作用

Php Drupal钩子\用户\更新不起作用,php,datetime,drupal,drupal-7,drupal-hooks,Php,Datetime,Drupal,Drupal 7,Drupal Hooks,我想要用户配置文件详细信息的上次更新时间。因此,我创建了一个带有字段(id、uid、changed)的表user_changes。当我使用这个钩子\用户\更新钩子时,数据不会插入到表中。我在我的主题的template.php中使用这个函数 function garland_user_update(&$edit, $account, $category) { db_insert('user_changes')->fields(array( 'uid' => $a

我想要用户配置文件详细信息的上次更新时间。因此,我创建了一个带有字段(id、uid、changed)的表user_changes。当我使用这个钩子\用户\更新钩子时,数据不会插入到表中。我在我的主题的template.php中使用这个函数

function garland_user_update(&$edit, $account, $category) {
    db_insert('user_changes')->fields(array(
    'uid' => $account->uid,
    'changed' => time(),
    ))->execute();
    exit; 
}

如果你需要任何细节,请告诉我。提前谢谢

钩子必须在模块中实现,而不是在主题中实现。为此,请选择一个名称(例如,
example
),在
sites/all/modules
中按该名称创建目录,创建包含内容的
example.info
文件

name = Example
description = Does some fancy stuff in certain situations
core = 7.x
在该目录中,将函数放入
sites/all/modules/example/example.module
。您还必须将函数重命名为
example\u user\u update

进一步阅读:

  • ,用于调用钩子实现的函数

  • 嗨,奥斯瓦尔德,你能再帮我一个忙吗?我相信你可以很容易地解决这个问题。我昨天才发布了这个问题。你能检查一下吗?如果你需要更多的澄清,请告诉我