Skip to content

Instantly share code, notes, and snippets.

@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;
});
@MrVibe
MrVibe / functions.php
Last active November 27, 2021 10:21
Stop user from Starting a course if profile incomplete. WPLMS V4
add_filter('wplms_before_course_status_api',function($stop,$course_id,$user_id){
$groups = bp_xprofile_get_groups( array(
'fetch_fields' => true
) );
$cflag= 1;
foreach($groups as $group){
if(!empty($group->fields)){
foreach ( $group->fields as $field ) {
if($cflag ){
@MrVibe
MrVibe / Leaderboard
Last active June 11, 2021 13:32
Course leaderboard
class WPLMS_Course_Leaderboard{
public static $instance;
public static function init(){
if ( is_null( self::$instance ) )
self::$instance = new WPLMS_Course_Leaderboard();
return self::$instance;
@MrVibe
MrVibe / functions.php
Created April 27, 2021 05:25
Custom fields in Registration popup v4
//Add custom field
add_filter('vibebp_vars',function($vars){
$vars['settings']['registration_fields'][]=['type'=>'text','id'=>'XXXXX','label'=>_x('WPLMS Purchase Code','login','vibebp'),'value'=>'','class'=>'input'];
return $vars;
});
//Process custom field
add_filter('vibebp_register_user_bypass',function($flag,$body){
foreach($body as $key => $value){
if($value['type'] == 'password'){