2014-05-07 63 views
0

我想要用户配置文件详细信息的上次更新时间。所以我创建了一个表user_changes与字段(id,uid,更改)。当我使用这个hook_user_update挂钩时,数据不会被插入到表中。我用我的主题的template.php文件这一功能Drupal hook_user_update不工作

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

让我知道如果你想要的任何细节。提前致谢。

回答

2

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

name = Example 
description = Does some fancy stuff in certain situations 
core = 7.x 

创建example.info文件,并把你的功能sites/all/modules/example/example.module。您还必须将您的功能重命名为example_user_update

进一步阅读:

+0

感谢您的回复。我现在正在创建一个模块 – Ananth

+0

现在它的工作。非常感谢 – Ananth

+0

嗨奥斯瓦尔德,你能再帮我一次吗?我相信你可以轻松解决这个问题。我昨天只发布了这个问题。你可以检查吗? http://stackoverflow.com/questions/23496574/drupal-dynamic-select-list-not-reterving-values-in-subcategory-field – Ananth