Guest User

Untitled

a guest
Mar 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. add_filter('wplms_course_credits','wplms_show_new_course_student_status',9999,2);
  2. function wplms_show_new_course_student_status($credits,$course_id){
  3. if(is_user_logged_in() && !is_singular('course')){
  4. $user_id=get_current_user_id();
  5. $check=get_user_meta($user_id,$course_id,true);
  6. if(isset($check) && $check){
  7. if($check < time()){
  8. return '<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('EXPIRED %s COURSE','vibe'),'<span class="subs">').'</span></strong></a>';
  9. }
  10.  
  11. $check_course= bp_course_get_user_course_status($user_id,$course_id);
  12. $new_check_course = get_user_meta($user_id,'course_status'.$course_id,true);
  13. if(isset($new_check_course) && is_numeric($new_check_course) && $new_check_course){
  14. switch($check_course){
  15. case 1:
  16. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('START %s COURSE','vibe'),'<span class="subs">').'</span></strong></a>';
  17. break;
  18. case 2:
  19. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('CONTINUE %s COURSE','vibe'),'<span class="subs">').'</span></strong></a>';
  20. break;
  21. case 3:
  22. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('UNDER %s EVALUATION','vibe'),'<span class="subs">').'</span></strong></a>';
  23. break;
  24. case 4:
  25. $marks = get_post_meta($course_id,$user_id,true);
  26. if(isset($marks)){
  27. $marks = '('.$marks.')';
  28. }
  29.  
  30. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('FINISHED %s COURSE','vibe'),'<span class="subs">').'</span></strong></a>'.$marks;
  31. break;
  32. default:
  33.  
  34. $credits =apply_filters('wplms_course_status_display','<a href="'.get_permalink($course_id).'"><strong>'.sprintf(__('COURSE %s ENABLED','vibe'),'<span class="subs">').'</span></strong></a>',$course_id);
  35. break;
  36. }
  37. }else{
  38. switch($check_course){
  39. case 0:
  40. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.__('START','vibe').'<span class="subs">'.__('COURSE','vibe').'</span></strong></a>';
  41. break;
  42. case 1:
  43. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.__('CONTINUE','vibe').'<span class="subs">'.__('COURSE','vibe').'</span></strong></a>';
  44. break;
  45. case 2:
  46. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.__('UNDER','vibe').'<span class="subs">'.__('EVALUATION','vibe').'</span></strong></a>';
  47. break;
  48. default:
  49. $marks = get_post_meta($course_id,$user_id,true);
  50. if(isset($marks)){
  51. $marks = '('.$marks.')';
  52. }
  53. $credits ='<a href="'.get_permalink($course_id).'"><strong>'.__('FINISHED','vibe').'<span class="subs">'.__('COURSE','vibe').'</span></strong></a>'.$marks;
  54. break;
  55. }
  56. }
  57. }
  58. }
  59.  
  60. return $credits;
  61. }
Add Comment
Please, Sign In to add comment