Join or create group on registration When people register for my site I want them to either join an existing group or create a new one if it doesn't exist. They can only be a member of one group, and there's only one group type used on the site.

I've got the autocomplete widget set and I want to alter it's functionality so instead of throwing an error message it creates a group. I presume altering og.module is not a good idea as it wouldn't be easy to make my particular changes generic enough to work for lots of use cases so am I right in thinking I would create a custom module to hook into the pre-save functionality of the user entity and do my checking to see if exists, if not then create group and create membership there or is there another way?

I tried using taxonomy as my group content and using a term reference autocomplete field on my user profile, but og doesn't seem to work fully with taxonomy at the moment, and I had other problems with attached field data not saving on taxonomy so gone back to using a node type as my group content type.
I think your general premise is sound. I'd be tempted to use hook_user_insert() instead, which is called after the user has been created, rather than before, since:


Your module can't actually fail to create a group or insert a new one.
hook_user_presave is really for modules that want to serialize (simple) data to be stored in the users table itself, which isn't what you're doing.


The necessary hooks in OG7 are all there for checking and creating groups and inserting users.