paid groups

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.

Was this article helpful?

2 Comments

  1. Autohr

    Hi How do I create paid groups, I tried this snippet ut does not work.

    I want to allow resellers that purchased course batches to be able to sell batch seats as wc products separate from course pages

Leave A Comment?