使用Drupal Rules模块按id加载内容

时间:2011-09-06 20:20:02

标签: drupal-6

想要根据特定条件(基本上只是在创建新帐户时)将文件添加到Drupal6用户的帐户。我想使用规则模块来完成此操作,但条件项似乎不包括此操作。可能如果您选择“执行自定义PHP代码”,这是可能的,但这是我的编程联盟。欢迎任何想法。

1 个答案:

答案 0 :(得分:1)

mmmm好吧也许你会发现创建一个新模块是困难的,但它很容易..小时候做

1-转到/ sites / all / modules

2-创建名为when_user_login的新文件夹(让我们将新模块称为when_user_login)

3-在此文件夹中创建when_user_login.info包含以下代码

name = when user login 
description = this module do something when user login
core = 6.x

4-现在让我们在同一目录中创建一个名为when_user_login.module的新文件包含以下代码

/**
* Implementation of hook_user().
* @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_user/6
* for more details
*/    

function when_user_login_user($op, &$edit, &$account, $category = NULL) {
switch($op){
  case 'insert' : 
  // now any code we will write here will be implemented when new user register
  // you can access the new user information by {$account} variable
  // E.g $account->uid include the id of the new account that register


  break ; 
}
}
祝你好运......跳跃会帮助你(不要忘记启用模块)

相关问题