Drupal 使用规则:用户在有机组逻辑中?
Drupal using rules: User is in organic group logic?
我正在尝试使用规则模块使用户具有依赖于有机组值列表的角色。我不能使用数据比较字段,因为它似乎只比较确切的列表值。例如,如果我的数据比较中有数字 1、2、3、4,但我的有机组列表中有 1、2、3、4、5 值,我无法分配角色。 None 的其他选择我有道理。
我的问题是:如何根据有机组列表中的值使用规则模块将用户分配给 Drupal 7 中的角色?
感谢您的帮助。
我认为您必须创建自己的规则条件。这通过使用自定义模块非常简单。
首先,您必须实施 hook_rules_condition_info(有关详细信息,请参阅 hook_rules_condition_info。)
function mymodule_rules_condition_info() {
return array(
'mymodule_og_condition_compare' => array(
'label' => t('Textual comparison'),
'parameter' => array(
'text1' => array(
'label' => t('Text 1'),
'type' => 'text',
),
'text2' => array(
'label' => t('Text 2'),
'type' => 'text',
),
),
'group' => t('Rules'),
),
);
然后您必须创建一个自定义函数,将您的值与 returns TRUE 或 FALSE 进行比较。
function mymodule_og_condition_compare($node, $node_unchanged){
//Compare values an return TRUE or FALSE
}
我正在尝试使用规则模块使用户具有依赖于有机组值列表的角色。我不能使用数据比较字段,因为它似乎只比较确切的列表值。例如,如果我的数据比较中有数字 1、2、3、4,但我的有机组列表中有 1、2、3、4、5 值,我无法分配角色。 None 的其他选择我有道理。
我的问题是:如何根据有机组列表中的值使用规则模块将用户分配给 Drupal 7 中的角色?
感谢您的帮助。
我认为您必须创建自己的规则条件。这通过使用自定义模块非常简单。
首先,您必须实施 hook_rules_condition_info(有关详细信息,请参阅 hook_rules_condition_info。)
function mymodule_rules_condition_info() {
return array(
'mymodule_og_condition_compare' => array(
'label' => t('Textual comparison'),
'parameter' => array(
'text1' => array(
'label' => t('Text 1'),
'type' => 'text',
),
'text2' => array(
'label' => t('Text 2'),
'type' => 'text',
),
),
'group' => t('Rules'),
),
);
然后您必须创建一个自定义函数,将您的值与 returns TRUE 或 FALSE 进行比较。
function mymodule_og_condition_compare($node, $node_unchanged){
//Compare values an return TRUE or FALSE
}