Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Created November 25, 2021 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrVibe/328041034a2ba5be4f1cf790316d3073 to your computer and use it in GitHub Desktop.
Save MrVibe/328041034a2ba5be4f1cf790316d3073 to your computer and use it in GitHub Desktop.
WPLMS My Courses shortcode
add_shortcode('my_courses',function($atts,$content=null){
if(empty($atts['user_id'])){
$user_id = get_current_user_id();
}else{
$user_id = $atts['user_id'];
}
$course_ids = bp_course_get_user_courses($user_id);
$return = '<div class="mycourses_wrapper" style="display:grid;grid-gap:1rem;grid-template-columns:repeat(auto-fit,minmax(320px,1fr))">';
if(!empty($course_ids)){
foreach($course_ids as $course_id){
$return .= thumbnail_generator($course_id,'course2','medium',1,1,1);
}
}
$return .='</div>';
reutnr $return;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment