Buddyboss custom code

i’m trying to make registration pages that sign people up to specific groups:

https://www.buddyboss.com/resources/docs/components/registration/registration-pages/

I found this code that adds all registrants to one group.

//Automatically add new users to a group
function automatic_group_membership( $user_id ) { if( !$user_id ) return false; groups_accept_invite( $user_id, 12 ); } add_action( ‘bp_core_activated_user’, ‘automatic_group_membership’ );

buddyboss support told me that the following plugin can do it:

https://wordpress.org/plugins/paid-memberships-pro/
https://wordpress.org/plugins/pmpro-buddypress/

but that’s yet another expense and I doubt it would work that easily anyway. We’re looking for a snippet of code like “if from postid#”, then to this grouI