Please add this code in your wplms-customizer.php file in wplms customizer plugin :
add_filter('wplms_product_metabox','group_connect');
function group_connect($product_metabox){
$product_metabox[]=array( // Single checkbox
'label' => __('Connect group','vibe-customtypes'), // <label>
'desc' => __('Group','vibe-customtypes'), // description
'id' => 'vibe_group_product', // field id and name
'type' => 'groups'
);
return $product_metabox;
}
add_action('woocommerce_order_status_completed','add_student_to_group');
function add_student_to_group($order_id){
$order = new WC_Order( $order_id );
$items = $order->get_items();
$user_id=$order->user_id;
foreach($items as $item_id=>$item){
$product_id = apply_filters('bp_course_product_id',$item['product_id'],$item);
$group_id= get_post_meta($product_id,'vibe_group_product',true);
if(isset($group_id) && is_numeric($group_id) && !empty($group_id))
groups_join_group($group_id, $user_id );
}
}
Now create a product and connect a group in it :

Now if user purchase this product then user will be added to the group which was connected to the product.
