Home › Forums › Legacy Support › Support queries › Other issues › code don't work
- This topic has 1 reply, 2 voices, and was last updated 9 years ago by Anshuman Sahu.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
November 4, 2015 at 9:41 am #6922trapaniettechSpectatorhi, this code : https://wplms.io/support/knowledge-base/reset-course-on-finish/ don't work and don't reset completely the course.... the string remain "finish course" and don't resetNovember 5, 2015 at 1:23 pm #7202Anshuman SahuKeymasterPlease try this code : the " bp_course_update_user_course_status " will update the status also . add_action('wplms_evaluate_course','course_reset_on_finish',999,3); function course_reset_on_finish($course_id,$marks,$user_id){ $status = bp_course_get_user_course_status($user_id,$course_id); if(isset($status) && is_numeric($status)){ // Necessary for continue course bp_course_update_user_course_status($user_id,$course_id,0); $course_curriculum=vibe_sanitize(get_post_meta($course_id,'vibe_course_curriculum',false)); update_user_meta($user_id,'progress'.$course_id,0); foreach($course_curriculum as $c){ if(is_numeric($c)){ delete_user_meta($user_id,$c); delete_post_meta($c,$user_id); if(get_post_type($c) == 'quiz'){ $questions = vibe_sanitize(get_post_meta($c,'quiz_questions'.$user_id,false)); if(!isset($questions) || !is_array($questions)) // Fallback for Older versions $questions = vibe_sanitize(get_post_meta($c,'vibe_quiz_questions',false)); else delete_post_meta($c,'quiz_questions'.$user_id); // Re-capture new questions in quiz begining if(isset($questions) && is_array($questions) && is_Array($questions['ques'])) foreach($questions['ques'] as $question){ global $wpdb; if(isset($question) && $question !='' && is_numeric($question)) $wpdb->query($wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='trash' WHERE comment_post_ID=%d AND user_id=%d",$question,$user_id)); } } } } /*=== Fix in 1.5 : Reset Badges and CErtificates on Course Reset === */ $user_badges=vibe_sanitize(get_user_meta($user_id,'badges',false)); $user_certifications=vibe_sanitize(get_user_meta($user_id,'certificates',false)); if(isset($user_badges) && is_Array($user_badges) && in_array($course_id,$user_badges)){ $key=array_search($course_id,$user_badges); unset($user_badges[$key]); $user_badges = array_values($user_badges); update_user_meta($user_id,'badges',$user_badges); } if(isset($user_certifications) && is_Array($user_certifications) && in_array($course_id,$user_certifications)){ $key=array_search($course_id,$user_certifications); unset($user_certifications[$key]); $user_certifications = array_values($user_certifications); update_user_meta($user_id,'certificates',$user_certifications); } /*==== End Fix ======*/ echo '<p>'.__('Course Reset for User','vibe').'</p>'; do_action('wplms_course_reset',$course_id,$user_id); } }
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- The topic ‘code don't work’ is closed to new replies.