【问题标题】:Drupal hook_user_update is not workingDrupal hook_user_update 不工作
【发布时间】:2014-05-07 06:14:28
【问题描述】:

我想要用户个人资料详细信息的最后更新时间。所以我创建了一个带有字段(id、uid、changed)的表 user_changes。当我使用这个 hook_user_update 钩子时,数据不会插入到表中。我在我的主题的 template.php 中使用了这个函数

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

如果您需要任何详细信息,请告诉我。提前致谢。

【问题讨论】:

    标签: php datetime drupal drupal-7 drupal-hooks


    【解决方案1】:

    钩子必须在模块中实现,而不是在主题中。为此,选择一个名称(例如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_user_update

    进一步阅读:

    【讨论】:

    • 嗨奥斯瓦尔德,你能再帮我一个忙吗?我相信您可以轻松解决此问题。我昨天才发布了这个问题。你能检查一下吗? stackoverflow.com/questions/23496574/…
    • 如果您需要更多说明,请告诉我
    猜你喜欢
    • 2012-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多