Skip to content

Instantly share code, notes, and snippets.

@MrVibe
MrVibe / functions.php
Last active October 28, 2021 08:55
Direct checkout WPLMS pluign
add_action('template_redirect',function(){
if( is_single() && get_post_type() == 'product' && isset($_GET['redirect'])){
global $woocommerce;
$found = false;
$product_id = get_the_ID();
$courses = vibe_sanitize(get_post_meta(get_the_ID(),'vibe_courses',false));
if(isset($courses) && is_array($courses) && count($courses)){
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
@MrVibe
MrVibe / functions.php
Created October 9, 2021 07:20
Add start date in Batch list in Courses [ v3 & v4 ]
add_action('wplms_batches_extras',function($batch_id){
$start_batch_date = groups_get_groupmeta($batch_id,'start_batch_date');
if(!empty($start_batch_date)){
echo 'STARTS '.wp_date( get_option( 'date_format' ), $start_batch_date );
}
},10,1);
@MrVibe
MrVibe / functions.php
Created October 4, 2021 07:03
Show quiz stats in single quiz page
add_action('wplms_front_end_quiz_end',function($quiz_id){
?>
<div class="container">
<ul class="data_stats" style="position:relative" data-id="<?php echo $quiz_id; ?>" data-type="quiz">
<li><a id="download_Stats" class="button full">View quiz stats</a></li>
</ul>
<div class="main_content">
</div>
@MrVibe
MrVibe / functions.php
Created September 25, 2021 10:59
Elementor Pro in Course header fix for WPLMS. Available in WPLMS 4.1 , paste code on child theme - functions.php
add_action('init',function(){
if(class_exists('ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager')){
$init = new ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager();
add_action( 'template_redirect', [ $init, 'register_locations' ] ,1);
}
},1);
@MrVibe
MrVibe / functions.php
Created September 18, 2021 14:05
Convert time to hours in Elemntor Course information widget.
add_filter('wplms_cs_get_course_unit_durations',function($human_time,$time_in_seconds){
return $time_in_seconds/3600.' hours';
},10,2);
@MrVibe
MrVibe / functions.php
Created September 13, 2021 06:52
Change curriculum Unit Icons
add_filter('wplms_get_element_icon',function($icon,$type){
if($type == 'video'){
$icon = 'YOUR ICON CLASS';
}
return $icon;
},10,2);
@MrVibe
MrVibe / functions.php
Created September 13, 2021 06:31
Remove Course Tabs from Single course view in Enrolled courses
add_filter('wplms_get_course_tabs',function($tabs){
unset($tabs['announcementsnews']);
unset($tabs['qna']);
unset($tabs['notes']);
return $tabs;
});
@MrVibe
MrVibe / functions.php
Created September 9, 2021 15:33
Disable Course application mode when 10 applications are recieved. Applications is disabled and Course returns to previous pricing mode which was set.
add_action('wplms_user_course_application',function($course_id){
global $wpdb;
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = 'apply_course$course_id'");
if($count >=10){
update_post_meta($course_id,'vibe_course_apply','H'); //Disable Course Applications, returns to previous pricing mode.
}
},10,1);
@MrVibe
MrVibe / header.-mooc.php
Created August 20, 2021 06:18
Udemy style ehader
<?php
//Header File
if ( ! defined( 'ABSPATH' ) ) exit;
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<?php
wp_head();
@MrVibe
MrVibe / functions.php
Created August 4, 2021 06:40
VibeBP Login redirect
add_filter('jwt_auth_token_validate_before_dispatch',function($data){
$data['redirect_component'] ='https://YOUR redirect page URL';
return $data;
});