Created
November 25, 2021 04:25
-
-
Save MrVibe/328041034a2ba5be4f1cf790316d3073 to your computer and use it in GitHub Desktop.
WPLMS My Courses shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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