简体   繁体   English

根据Profile2字段使用规则添加用户角色

[英]Add user role based on Profile2 Field Using Rules

What I am trying to achieve is: 1) I have a Profile2 field in the user registration form called: "Firm Type" 2) I need to assign the new user a Role based on the selection in this field. 我想要达到的目的是:1)我在用户注册表单中有一个Profile2字段,名称为:“ Firm Type” 2)我需要根据此字段中的选择为新用户分配一个Role。

I have tried the following: 我尝试了以下方法:

Event: After saving a new account Condition: Data Comparison: account:profile-additional-registration-info:field-profile-firm-type Action: Add a user role 事件:保存新帐户后条件:数据比较:account:profile-additional-registration-info:field-profile-firm-type 操作:添加用户角色

The above Rule works fine when I remove the condition. 当我删除条件时,上述规则可以正常工作。 As soon as I add the condition the rule does not work. 添加条件后,该规则将不起作用。 Digging into this I found out that Rule gets executed after Account is saved and before Profile2 is saved. 对此进行研究,我发现在保存帐户之后和保存Profile2之前将执行规则。

I looked online to find these 2 links helpful: https://www.drupal.org/node/1872384 https://www.drupal.org/node/2009878 我在网上寻找以下两个有用的链接: https : //www.drupal.org/node/1872384 https://www.drupal.org/node/2009878

1 suggestion was: Event: After saving a new profile Condition: Data Comparison: Profile2:field Action: Heres where the problem is -- I cannot get to the account level because its on a profile event. 一个建议是: 事件:保存新的配置文件后条件:数据比较:Profile2:field 操作:这是问题所在–我无法进入帐户级别,因为它在配置文件事件中。

Could you please help me figure this out. 你能帮我解决这个问题吗? Any help would be really appreaciated! 任何帮助将不胜感激! Thanks! 谢谢!

Here are the steps: 步骤如下:

  • Rules Event : After adding a new profile After updating an existing profile 规则事件 :添加新配置文件后更新现有配置文件后

  • Rules Condition : Negate User Has Roles: Check all roles other than a Public Role Data Comparison: profile2:field 规则条件 :否定用户具有角色:检查公共角色以外的所有角色数据比较:profile2:field

  • Rules Action : Set a Data Value: site:current-user:roles 规则操作 :设置数据值: site:current-user:roles

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为drupal中每个用户角色的profile2登录/注册页面创建自定义模板文件 - How to create custom template file for login/register pages of profile2 each user role in drupal Drupal Profile2 /字段集合排序记录 - Drupal Profile2 / Field collection sorting records 如何在drupal profile2中存储用户的兴趣? - How to store user's interest in the drupal profile2? 如何删除Drupal profile2模块及其创建的所有用户配置文件表 - How do I remove Drupal profile2 module and all user profile tables it created 将profile2配置文件添加到drupal7中的面板 - Adding profile2 profile to panel in drupal7 Drupal:将联系表单作为字段添加到用户个人资料 - Drupal: add contact form as field to user profile 在Drupal 6中根据注册字段组合设置新用户的角色 - Setting the new user's role based on registration field combo in Drupal 6 Drupal-(Profile2)概要文件类型在多步向导中不显示表单 - Drupal - (Profile2) Profile types does not show form on multistep wizard 合并2个用户个人资料字段以在整个字段中提供“添加更多” - Combine 2 user profile fields to provide “Add More” to the whole field 根据用户管理员修改的配置文件变量为特定用户添加内容 - Add content for particular users based on profile variables modified by User admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM