Check out the “Auto Join Groups” plugin:
http://brentandmary.net/2009/10/24/bn-auto-join-group-plugin/
The plugin is more about targetting than having everyone join each group, but you should be able to play around with it to fit your needs.
This thread has someone who wants the same thing: https://buddypress.org/forums/topic/join-all-public-groups-at-once Maybe you can work together or see if they’ve found the solution beyond r-a-y’s link which is good.
if you want to keep it all using bp functions, look at bp-groups.php
I would set it up hooking on activating the user (or signup if you don’t care about the activation key)
_action( 'bp_core_activated_user'
then call (with no pagination passed in and active type)
groups_get_groups(
then loop over all the groups and call (which needs the user_id and group_id)
groups_join_group(
only downside to join_group is it will call a new activity for joining – but a plus side is it updates the groupmeta counts.
*my standard disclaimer applies – only in theory nothing tested.