Skip to content

Instantly share code, notes, and snippets.

Avatar

Anshuman Sahu alexvibealex

  • 99fusion
  • Noida
View GitHub Profile
View gist:0d61687dd2a4139c4f5ed3a7d9212196
add_shortcode('course_leaderboard',function ($atts,$content=null){
ob_start();
global $wpdb;
if(!isset($atts['count'])){
$atts['count'] =10;
}
$students = $wpdb->get_results($wpdb->prepare("
@alexvibealex
alexvibealex / check profile complete on start course
Created May 26, 2021
check profile complete on start course
View check profile complete on start course
add_filter('wplms_before_course_status_api','wplms_before_course_status_api2',99,3);
function wplms_before_course_status_api2($stop,$course_id,$user_id){
$cflag = 1;
$groups = bp_xprofile_get_groups( array(
'fetch_fields' => true
) );
foreach($groups as $group){
if(!empty($group->fields)){
foreach ( $group->fields as $field ) {
View gist:572a1909d6d79301b0be89fc9f7d2961
add_filter('vibebp_profile_field_block_value',function($value,$field){
if(strpos($value, 'https')!==false && $field->id==17){ //replace 17 with your profile field id
global $wp_embed;
$value = $wp_embed->run_shortcode('[embed]'.$value.'[/embed]');
}
return $value.'<style>.vibebp_profile_field.field_'.$field->id.'>div{ display:block;}.field_'.$field->id.' .fitvids iframe{min-height:500px;}</style>';
},10,2);
View maintain state into eventlisnter
useEffect(()=>{
if(props.field && props.field.id){
document.addEventListener('vibe_editor_content_update_'+props.field.id+random,eventCapturer,false);
}
return ()=>{
if(props.field && props.field.id){
document.removeEventListener('vibe_editor_content_update_'+props.field.id+random,eventCapturer);
}
}
@alexvibealex
alexvibealex / elementor pro not working in front end
Created Feb 10, 2021
elementor pro not working in front end
View elementor pro not working in front end
add_action('wp_head',function(){
global $post;
if(!class_exists('\Elementor\Frontend'))
return;
$elementorFrontend = new \Elementor\Frontend();
$elementorFrontend->enqueue_scripts();
@alexvibealex
alexvibealex / gist:9a1a452a59ddaf6ab827f5a3c78f6fda
Created Feb 5, 2021
timepicker not closing on choosing date fix
View gist:9a1a452a59ddaf6ab827f5a3c78f6fda
add_action('admin_head',function(){
?>
<script>jQuery.browser = {};
(function () {
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
@alexvibealex
alexvibealex / Oembed run over post content
Last active Nov 23, 2020
Oembed run over post content and wpautop
View Oembed run over post content
add_action('init',function(){
global $wp_embed;
$obj = new Vibe_Define_Shortcodes();
add_filter( 'vibebp_media_filter', array( $wp_embed, 'autoembed' ), 8 );
remove_shortcode('course_info',array($obj,'course_info'));
add_shortcode('course_info','course_info2');
});
function course_info2($atts,$content=null){
extract(shortcode_atts(array(
@alexvibealex
alexvibealex / gist:2bd658ed00ce6e3f00faa6b3e7bd0f5c
Created Oct 28, 2020
lock assignment with submit action fix
View gist:2bd658ed00ce6e3f00faa6b3e7bd0f5c
add_action('wplms_before_single_assignment','wplms_check_wplms_assignment_submission2',10);
function wplms_check_wplms_assignment_submission2(){
if(is_user_logged_in()){
$user_id = get_current_user_ID();
$assignment_id = get_the_ID();
$status = get_post_meta($assignment_id,$user_id,true);
View bp-course-ajax.php
<?php
/**
* Ajax functions for Course Module
*
* @author VibeThemes
* @category Admin
* @package Vibe Course Module
* @version 2.0
*/
@alexvibealex
alexvibealex / gist:3be1b83eb535add300a718e8076e3c59
Last active Aug 21, 2020
assign full commission even when coupon applied
View gist:3be1b83eb535add300a718e8076e3c59
add_filter('bp_course_record_instructor_commission',function ($commission,$instructor_id,$course_id,$meta){
if(!function_exists('wc_get_product'))
return $commission;
if(!empty($meta['order_id'])){
$order = new WC_Order( $meta['order_id']);
$items = $order->get_items();
if(!empty($items)){
foreach ( $items as $key=> $item ) {
if($meta['item_id'] == $key){