Using D7 OG I want to force (auto) join - any ideas? I'm using D7 Organic Groups to create custom member profiles such that when a new user registers, a rule creates a group with their name (/member/firstname-lastname) and redirects them to their group's home page where there is a "build-profile" panel using quicktabs to guide them through the 7 steps of building a complete profile.  The build panel is visible until such time as they complete the final step at which point they are autoassigned a new role which uses a different page layout sans the build panel.  

This all works well.  When users browse for other users they are actually directed to the associated /member/firstname-lastname page for the user whose profile they are viewing.

Here is the issue I'm now having.  I need to make it so that when a user "follows" another user (joins or subscribes-to their group) I want the owner of the group being followed to automatically "follow" (join or subscribe-to) their group.

This is really only doable because each member only "owns" or is admin to a single group, so it should be relatively easy to say - if user-a (owner of group-a) joins group-b (owned by user-b) then user-b joins group-a.

I'm just not sure programatically how to do this.  Can anyone help me with a code snippet to do this?
I'm going to assume that you are using the 7.x-1.x branch of Organic groups. I believe there are some major changes in the 2.x branch - so this solution may/may not work with that.

// Assuming your group is of the entity type "node"
// and the name of your bundle is "group". A node bundle
// is the unique name of the content type which is a group
// type as well.
// Say $follower is the follower user entity and 
//     $followee is the followee user entity
$opts = array(
  ':uid' =&gt; $follower-&gt;uid
  ':type' =&gt; 'group'
);
$gnid = db_query('SELECT nid FROM {node} WHERE type=:type AND uid=:uid', $opts)-&gt;fetchField();
if ($gnid) {
  $group = og_get_group('node', $gnid);
  og_group($group-&gt;gid, array(
    'entity type' =&gt; 'user',
    'entity' =&gt; $followee,
    'state' =&gt; OG_STATE_ACTIVE
  ));
}
else {
  watchdog('my_mod', 'Follower (uid=!uid) does not have a member group', array(':uid' =&gt; $follower-&gt;uid), WATCHDOG_ERROR);
}


Still, own (group manager) and is admin of are two different things, at least in OG parlance. Because a user may have the "administrator user" role in many groups. If you mean is admin of, the lookup of the node table above may have to be changed by doing a join with {og} and {og_users_roles}.