To automatically join new users to an existing group on your BuddyPress site, you will need to add a function to your functions.php file. Add this function, replacing <# group ID #> on line five with the numeric ID of your group.


//Automatically add new users to a group
function automatic_group_membership( $user_id ) {

if( !$user_id ) return false;
groups_accept_invite( $user_id, <# group ID #> );
}
add_action( ‘bp_core_activated_user’, ‘automatic_group_membership’ );

You will need to figure out the group’s numeric ID. Here’s a trick. If you have Firebug installed with Firefox, you can click on your group and then select the group’s avatar within Firebug. It will say the group’s number in the avatar’s image class. It will be something along the lines of: img class=”avatar group-2-avatar”.

Leave a Comment

Your email address will not be published. Required fields are marked *