How to limit a user to specific OG groups based on user role?
Due to other restrictions in OG I couldn't overcome, I ended up using the Group module instead. In addition to other advantages for my use case, it offers some functions to easily add group memberships (these are entities) by using something like

$entity_type = 'group_membership';
$entity = entity_create($entity_type, array('gid' =&gt; $gid, 'uid' =&gt; $uid));
$wrapper = entity_metadata_wrapper($entity_type, $entity);
$wrapper-&gt;status = 'active';
$wrapper-&gt;added_on = time();
$wrapper-&gt;added_by = 1;
$wrapper-&gt;save();


Adding that into a hook_user_update(&amp;$edit, $account, $category) function, I am able to add and revoke memberships based on the updated account's roles.