Skip to content

Instantly share code, notes, and snippets.

@MrVibe
MrVibe / functions.php
Created December 7, 2018 16:18
Show number of Certificates and Badges won by a Student
//USage : [wplms_student_certifiacate_badge_count type='certificate'] [wplms_student_certifiacate_badge_count type='badge']
//optionally mention user_id
add_shortcode('wplms_student_certifiacate_badge_count',function($atts,$content){
if(empty($atts['user_id'])){
if(is_user_logged_in()){
$atts['user_id] = get_current_user_id();
}else{
return;
@MrVibe
MrVibe / functions.php
Last active November 19, 2018 17:46
Add more schedule options for Course expiry email. Like notify student 30 days in advance.
add_filter('wplms_email_schedule',function($settings){
foreach($settings as $i=>$setting){
if($setting['name']==='expire_schedule'){
$hours = 30*24;
$settings[$i]['options'][$hours]='Before 30 days of course expiry';
$settings[$i]['options'][$hours*2]='Before 60 days of course expiry';
$settings[$i]['options'][$hours*3]='Before 90 days of course expiry';
}
}
@MrVibe
MrVibe / functions.php
Created November 13, 2018 17:54
Two checkbox in BuddyPress registration for European sites
add_action('bp_signup_validate', 'eu_terms_conditions_validation');
add_action('bp_before_registration_submit_buttons', 'eu_show_terms_conditions',1,1);
function eu_terms_conditions_validation(){
global $bp;
$custom_field = $_POST['eu_terms_conditions'];
if (empty($custom_field) || $custom_field == '') {
//ERROR MESSAGE
$bp->signup->errors['eu_terms_conditions'] = __('Please Check EU Terms & Conditions','vibe-customtypes');
@MrVibe
MrVibe / functions.php
Created November 3, 2018 01:30
WPLMS Show Course online/offline status in Course details
add_filter('wplms_course_details_array',function($details){
$details['unit_duration'] = array(
'label'=>_x('Course Offline/Online Status','label in details array','vibe-customtypes'),
'callback'=> 'custom_get_course_offline_online_status',
);
return $details;
});
function custom_get_course_offline_online_status(){
@MrVibe
MrVibe / style.css
Last active September 8, 2018 17:47
WPLMS Fullwidth videos in Courses like this : http://prntscr.com/ks4351
.unit_wrap .fitvids {
margin: 0 calc(-10% - 50px);
}.unit_wrap,.unit_content{overflow:visible;}
@MrVibe
MrVibe / functions.php
Created July 9, 2018 16:57
Custom Featured block example : http://prntscr.com/k4e4z9
add_filter('vibe_builder_thumb_styles',function($thumb_array){
$thumb_array['custom_block']= 'https://i1.wp.com/i.imgur.com/gxrPvvJ.jpg?zoom=2&w=920';
return $thumb_array;
});
add_filter('vibe_featured_thumbnail_style',function($thumbnail_html,$post,$style){
if($style == 'custom_block' && $post->post_type == 'course'){ //Custom block is the same name as added for the thumbnail in pagebuilder
$thumbnail_html ='';
$thumbnail_html .= '<div class="block customblock">';
@MrVibe
MrVibe / functions.php
Last active July 7, 2018 17:00
Embedding Watupro quiz in WPLMS units.
add_action('wp_footer',function(){
?>
<script>
jQuery(document).ready(function($){
if($('body').hasClass('page-template-start-php')){
$('#watupro_quiz').each(function(){
let unit_id = $('.unit_line.active .unit').attr('data-unit');
$(this).next('form').append('<input type="hidden" name="no_ajax_course_id" value="'+$('#course_id').val()+'" /><input type="hidden" name="hash" value="'+$('#hash').val()+'" /><input type="hidden" name="load_unit" value="'+unit_id+'" />');
@MrVibe
MrVibe / functions.php
Created June 29, 2018 18:55
Show announcements in MyCourses section in profile.
add_action('bp_before_member_course_content',array('wplms_announcement','check_announcements'));
add_action('bp_before_member_course_content',function(){
wp_nonce_field( 'vibe_security', 'security');
?>
@MrVibe
MrVibe / functions.php
Created June 24, 2018 03:02
Redirect to WPLMS Batch on login if maintaining 1 batch per student.
add_filter('login_redirect',function($redirect_url,$request_url,$user){
global $bp;
if(($user instanceof WP_User)){
if(function_exists('wplms_get_user_batches')){
$batches = wplms_get_user_batches($user->ID);
if(!empty($batches)){
return bp_get_group_permalink($batches[0]);
}
}
}
@MrVibe
MrVibe / functions.php
Last active August 30, 2020 17:36
Get top 15 quiz scorers
add_shortcode('wplms_quiz_top_scorers',function($atts,$content = null){
extract(shortcode_atts(array(
'count' => 5,
)));
global $wpdb;