Custom VBO Action only works when enqueued (Adding User Role and Organic Group) I wrote a custom module to add a VBO action that allows an Admin of a group to search the sites users, add them to their list (adds a role to the select users to get them on the list) and then allows the Admin to optionally add the user to an organic group they also may admin. The role is added just fine, but the organic group won't 'stick' unless I enqueue the operation. When I don't enqueue the operation, I dpm'ed the call to og_group and it's returning a membership object and claims it was successful, but it clearly didn't save. I don't have any errors or notices in the logs either.
Here's my setup for saving the group/user relationship:

$values = array(
        'entity_type' =&gt; 'user',
        'entity' =&gt; $user,
        );

og_group('node', $group-&gt;nid, $values);


$user is a fully loaded user account and $group is the group node. I tried adding name_field and the group audience to the values array, but this made no difference.

Here's the hook for the VBO:

function vbo_users_to_groups_action_info() {
 return array(
   'vbo_users_to_groups_my_custom_action' =&gt; array(
   'type' =&gt; 'user',
   'label' =&gt; t('Add users to Pro List and optional Group'),
   'behavior' =&gt; array('changes_property'),
   'configurable' =&gt; TRUE,
   'vbo_configurable' =&gt; FALSE,
   'triggers' =&gt; array('any'),
   ),
  );
}


Is there anything else you need to see that may be causing this?
If anybody runs into this in the future, I had to pass the group id into the og_user_node field and save the user after calling og_group():

$values = array(
    'entity_type' =&gt; 'user',
    'entity' =&gt; $user,
    );

og_group('node', $group-&gt;nid, $values);
$data['og_user_node']['und'][0]['target_id'] = $groupid;
user_save($user, $data);


You should check for any other groups the user is in and create an array of groups along with the new group id and save that into og_user_node, but in my situation, users are only allowed in 1 group, so this takes care of putting them in the new group and removing the old one.