Students certificates shortcode

Please try adding the given code in your wplms-customizer.php file at the end before ” ?> ” in wplms customizer plugin :

add_shortcode('student_certificates_and_badges', 'student_certificates_shortcode');
function student_certificates_shortcode( $atts, $content = null ) {
     global $bp;
  if(function_exists('bp_displayed_user_id')){
    $user_id=bp_displayed_user_id();
  }

  if(empty($user_id) && is_user_logged_in()){
     $user_id=get_current_user_id();
  }else{
     return 'N.A';
  }

  extract(shortcode_atts(array(
      'id'       => $user_id,
      'badges'   => 0
       ), $atts));
  if(!empty($badges)){
    $bids=vibe_sanitize(get_user_meta($id,'badges',false));
  if(isset($bids) && is_Array($bids) && count($bids)){
      echo '<div class="badges"><h6>'.__('Badges','vibe').'</h6>';
      echo '<ul>';
        foreach($bids as $bid){
          $b='';
          if(function_exists('bp_get_course_badge'))
            $b=bp_get_course_badge($bid);
 
            $badge=wp_get_attachment_info($b); 
            $badge_url=wp_get_attachment_image_src($b,'full');
            if(isset($badge) && is_numeric($b)){
               echo '<li><a class="tip ajax-badge" data-course="'.get_the_title($bid).'" title="'.get_post_meta($bid,'vibe_course_badge_title',true).'">
               <img src="'.$badge_url[0].'" title="'.$badge['title'].'"/></a>
               </li>';
            }
        }
      echo '</ul>';
      echo '</div>';
   }  
  }
   
 
  
   $certis=vibe_sanitize(get_user_meta($id,'certificates',false));
   
     if(isset($certis) && is_Array($certis) && count($certis)){
          echo '<div class="certifications"><h3>'.__('Certifications','vibe').'</h3><ul class="">';
          if(isset($certis) && is_Array($certis)) 
           foreach($certis as $certi){
                  echo '<li style=" display: inline-block;margin: 10px;"><a href="'.bp_get_course_certificate('user_id='.$id.'&course_id='.$certi).'" class="ajax-certificate"><i class="icon-certificate-file"></i><span>'.get_the_title($certi).'</span></a></li>';
 
           }
         echo '</ul></div>';  
      }         
}

Use the shortcode like this : [student_certificates_and_badges]    .

You can also show other user certificates by specifying id in shortcode : [student_certificates_and_badges id=”2″]     
where 2 is the user id .

You can also enable to show badges like this :  [student_certificates_and_badges id=”2″ badges=”1″]    

Was this article helpful?

Related Articles

2 Comments

  1. zelimhan

    page load blank, can u please update this shortcode? i need this

Leave A Comment?