Buddypress how to create a group programmatically in PHP (and add users)

In this post I’ll show you how to¬†create a new group in PHP and then add users to the group. In this example I’m adding new users to a new group when they register. add_action(‘user_register’, ‘greenbox_add_user_to_new_buddypress_group’); //this should only fire on create user, therefore no problem with dupe groups function greenbox_add_user_to_new_buddypress_group($user_id) { $id_group = greenbox_create_bp_group($user_id); … Read more