This reply has been marked as private.
Well thanks for this code but its not working .
I first tried it with course id it did not work ,then I tried it with wp posts but again it did not work .Any reasons why the functions are not working on my setup ?
refer :
http://prntscr.com/jj2r3t
This reply has been marked as private.
Well that was a very valuable information.
I will try that code again once I will be back in office on Monday .
This reply has been marked as private.
Well yes this time it works but Im having a little problem assigning all versions of the courses in one go .It is getting stuck in a loop . Please provide me some time for this .
This reply has been marked as private.
This reply has been marked as private.
Hi I was able to develop this custom code to allocate the course when its translated course purchased . this code will work when course product is purchased and order gets completed . add it in your wplms-customizer.php file in wplms customizer plugin :
add_action('wplms_course_product_puchased',function($course,$user_id,$total_duration,$bool,$product_id,$item_id){
$trid = apply_filters('wpml_element_trid', null,$course,'post_course');
$translations = apply_filters('wpml_get_element_translations', null,$trid,'post_course' );
if(!empty($translations)){
foreach ($translations as $key => $value) {
if(!empty($total_duration)){
bp_course_add_user_to_course($user_id,$value->element_id,$total_duration,1);
}else{
bp_course_add_user_to_course($user_id,$value->element_id);
}
}
}
},10,6);
This reply has been marked as private.
I guess mistake was made in reading on where to add that code .
you have to add that code in your wplms-customizer.php file in wplms customizer plugin not in appearance -> customize .
This reply has been marked as private.
Please add this code in your wplms-customizer.php file in wplms customizer plugin :
add_action('wplms_course_code',function($code,$course_id,$user_id){
$trid = apply_filters('wpml_element_trid', null,$course_id,'post_course');
$translations = apply_filters('wpml_get_element_translations', null,$trid,'post_course' );
if(!empty($translations)){
foreach ($translations as $key => $value) {
bp_course_add_user_to_course($user_id,$value->element_id);
}
}
});
This reply has been marked as private.