Missing proper user update, after_update event

ckng - November 13, 2008 - 11:19
Project:Apply for role
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Apply for role module is doing modification to user role, however, it does not follows 'Drupal way' of user update process. Hence user update event - update & after_update are not fired.

Attached is the patch to add in the user update event when the user's roles are modified.

After which you can make use of module such as workflow_ng to create trigger when a user role changed.

AttachmentSize
apply_for_role_miss_user_invoke.patch3.38 KB

#1

ckng - November 13, 2008 - 11:33

Just in case someone needed this.
A sample workflow_ng rule to trigger when a role is approved.
For deletion or revoked rules, just clone the same rule and toggle the Negate of both conditions.

array (
  'cfg_6' =>
  array (
    '#event' => 'user_update',
    '#altered' => false,
    '#active' => 1,
    '#type' => 'configuration',
    '#label' => 'Your_Role role is approved',
    '#id' => 1,
    '#weight' => '0',
    '#module' => 'workflow-ng',
    0 =>
    array (
      '#name' => 'workflow_ng_condition_user_hasrole',
      '#id' => 2,
      '#type' => 'condition',
      '#label' => 'User has new role',
      '#settings' =>
      array (
        'roles' =>
        array (
          0 => 1,
        ),
        'operation' => 'OR',
      ),
      '#argument map' =>
      array (
        'account' => 'user',
      ),
    ),
    1 =>
    array (
      '#type' => 'action',
      '#name' => 'workflow_ng_action_mail',
      '#settings' =>
      array (
        'to' => '[account:mail]',
        'to_args' =>
        array (
          0 => 'account',
        ),
        'from' => 'your_email@example.com',
        'from_args' =>
        array (
        ),
        'subject' => 'Application for role "Your_Role" has been approved',
        'subject_args' =>
        array (
        ),
        'message' => '[account:user],

Your application for the role "Your_Role" in example.com has been approved.
',
        'message_args' =>
        array (
          0 => 'account',
          1 => 'account_unchanged',
        ),
      ),
      '#id' => 3,
    ),
    2 =>
    array (
      '#type' => 'condition',
      '#name' => 'workflow_ng_condition_user_hasrole',
      '#argument map' =>
      array (
        'account_unchanged' => 'user',
      ),
      '#negate' => 1,
      '#settings' =>
      array (
        'roles' =>
        array (
          0 => 1,
        ),
        'operation' => 'OR',
      ),
      '#label' => 'User has no Your_Role role previously',
    ),
    '#name' => 'cfg_6',
  ),
)

#2

tborrome - January 10, 2009 - 17:54

Thanks, I'm about to try this out as I need this functionality.

do you have a workflow_ng rule for email to be sent to admin when a user applies for a role?

is this possible with applyforrole with workflow-ng?

#3

Soren Jones - January 11, 2009 - 06:32
Status:needs review» postponed (maintainer needs more info)

Does #351916: Module should not directly manipulate users_roles table address this issue? If so it's been backported to 5 and is available in 5.x-1.8.

#4

ckng - April 6, 2009 - 14:30
Status:postponed (maintainer needs more info)» fixed

Yes, #351916: Module should not directly manipulate users_roles table solved the same problem.

#5

System Message - April 20, 2009 - 14:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.