0
votes

I've created an action programmatically and added a VBO to a view in order to execute the action on one or more users. The action itself simply removes a few roles and adds a new role to the selected users. I call user_save from within the action to save the changes to the roles.

If I look at the user_roles table in the database while the action is running, I can see the role ids for the specific user, changing to the new role in realtime. However, when the VBO is complete, it seems to revert back to the original user object so that none of the old roles have been removed and the new role hasn't been added. It has to be something happening after my action is executed, but I can't imagine what it is.

Oddly enough, if I run the VBO a second time, it seems to work.

My action is defined in hook_action_info as type "user" and triggers is an array with "any" as the only parameter.

If I call the action directly using actions_do, it works perfectly the first time.

Any ideas?

1

1 Answers

0
votes

I suggest to use a few users to test the VBO and also implement hook_user_update with dpm (devel module) and debug_backtrace. This could give a hint of what is happening, it's a weird behaviour that you will discover only debugging.

If you have more info please append it to your question so everyone could help.

Hope that helps.