Skip to content

Instantly share code, notes, and snippets.

@MrVibe
MrVibe / functions.php
Created March 3, 2020 11:19
Add Custom label in Batch Sidebar on Seats Full.
add_action('wplms_batches_extras',function($batch_id){
$enable_seats = groups_get_groupmeta($batch_id,'enable_seats');
if(!empty($enable_seats)){
$count = groups_get_total_member_count($batch_id);
$batch_seats = groups_get_groupmeta($batch_id,'batch_seats');
if($count >= $batch_seats){
echo '<a href="URL_TO_CONTACT_PAGE" class="full">'.__('Waiting','wplms-batches').'</a>';
}
}
@MrVibe
MrVibe / functions.php
Created February 7, 2020 16:58
Add a HelloBar like notification in WPLMS
add_filter('vibe_option_custom_sections',function($sections){
$sections[1]['fields'][]= array(
'id' => 'header_notification',
'type' => 'editor',
'title' => __('Header Notification', 'vibe'),
'sub_desc' => __('* Standard headers', 'vibe'),
'desc' => __('Add header notification', 'vibe'),
'std' => ''
);
return $sections;
@MrVibe
MrVibe / functions.php
Created January 22, 2020 14:20
Pmpro restriction on units in App.
add_filter('bp_course_api_get_user_course_status_item',function($return,$request){
$course_id = $request['course'];
$user_id = pmpro_get_user_from_token($request);
if(!empty($course_id) && !empty($user_id)){
$course_membership_ids = get_post_meta( $course_id, 'vibe_pmpro_membership', true );
if(!empty($course_membership_ids) && is_array($course_membership_ids)){
if(!pmpro_hasMembershipLevel($course_membership_ids,$user_id)){
$return = array(
'status' => 0,
'message' => 'Not access'
@MrVibe
MrVibe / wplms app
Last active August 12, 2021 14:51
Latest WPLMS App [November 2019] - Tested [6th March 2020] - [update 6th May]
Notice [6th May] : InAppBrowser version should be 3.2.0 and Ios Cordova version 5.1.1
/*====
Ionic:
Ionic CLI : 5.4.4
Utility:
@MrVibe
MrVibe / functions.php
Last active August 29, 2019 12:55
Record number of Words in tinyMCE editor in Units, shows alert when limit exceeds.
add_action('wp_footer',function(){
if(!is_page(vibe_get_option('create_course'))){
return;
}
?>
<script>
jQuery(document).ready(function($){
var word_limit = 200;
$('#course_curriculum').on('active',function(){
@MrVibe
MrVibe / functions.php
Created August 29, 2019 12:36
WPML Instructor course count
add_filter('wplms_get_instructor_course_count',function($count,$user_id){
$args = array(
'posts_per_page' => -1,
'post_type' => 'course',
'post_author'=>$user_id,
'suppress_filters' => false
);
$result = new WP_Query($args);
return $result->post_count;
@MrVibe
MrVibe / functions.php
Last active June 6, 2019 08:06
Batch filtering in Course - Admin area. see Video : https://www.youtube.com/watch?v=vYIl08c3C9U
add_action('wplms_course_admin_form',function($students,$course_id){
$batch_ids = wplms_get_course_batches($course_id);
echo '&nbsp;<select id="wplms_user_batch"><option value="">'.__('Filter by Batch','vibe').'</option>';
foreach($batch_ids as $batch_id){
echo '<option value="'.$batch_id.'">'.wplms_get_batch_link($batch_id).'</option>';
}
echo '</select>';
@MrVibe
MrVibe / taxonomy-course-cat.php
Created April 24, 2019 08:53
Full with Course category without sidebar
<?php
if ( !defined( 'ABSPATH' ) ) exit;
$redirect_course_cat_directory = vibe_get_option('redirect_course_cat_directory');
if(!empty($redirect_course_cat_directory)){
locate_template( array( 'course/index.php' ), true );
exit;
}
@MrVibe
MrVibe / functions.php
Created March 22, 2019 17:40
Custom featured block in Course directory
add_filter('bp_course_single_item_view',function($flag,$post){
$course_post_id = $post->ID;
$course_author= $post->post_author;
$course_classes = apply_filters('bp_course_single_item','course_single_item course_id_'.$post->ID.' course_status_'.$post->post_status.' course_author_'.$post->post_author,get_the_ID());
?>
@MrVibe
MrVibe / functions.php
Created December 15, 2018 14:21
WPLMS : Include all Quizzes connected to the course in Course evaluation irrespective whether they are included in the curriculum or not.
add_action('bp_get_course_check_course_complete',function($course_id,$user_id){
add_filter('bp_course_get_course_curriculum',function($curriculum,$course_id){
global $wpdb;
$quiz_ids = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key ='vibe_quiz_course' AND meta_value = %d",$course_id));
if(!empty($quiz_ids)){
foreach($quiz_ids as $quiz_id){
if(array_search($quiz_id, $curriculum) === false){
$curriculum[]=$quiz_id;
}