Skip to content

Instantly share code, notes, and snippets.

@MrVibe
MrVibe / functions.php
Created February 27, 2024 14:13
Exclude delay in course renewal Drip timer check
class Drip_Expired_Check{
public static $instance;
public $time_to_adjust = 0;
public static function init(){
if ( is_null( self::$instance ) )
self::$instance = new Drip_Expired_Check();
return self::$instance;
}
@MrVibe
MrVibe / functions.php
Created June 13, 2022 05:44
Verify if App page is loaded in correct language.
add_action('template_redirect',function(){
global $post;
if(is_page(vibebp_get_setting('bp_single_page'))){
$wpml_page_id = apply_filters('wplm_object_id',$post_id,'page');
if($post->ID != $wpml_page_id){
$new_url = str_replace(get_permalink($post->ID),get_permalink($wpml_page_id),$_SERVER['REQUEST_URI']);
wp_redirect($new_url);
exit;
}
}
@MrVibe
MrVibe / functions.php
Created June 1, 2022 12:36
create a static widget in boilerplate.
<?php
add_action( 'widgets_init', 'Sample_Widget' );
function Sample_Widget() {
register_widget('Sample_Widget');
}
class Sample_Widget extends WP_Widget {
@MrVibe
MrVibe / customizer_class.php
Last active April 12, 2022 02:46
Custom User field in Course stats download version 4 compatible.
<?php
if(!class_exists('WPLMS_Customizer_Plugin_Class'))
{
class WPLMS_Customizer_Plugin_Class // We'll use this just to avoid function name conflicts
{
public function __construct(){
add_filter('wplms_course_stats_list',array($this,'add_custom_course_stat'));
add_action('wplms_course_stats_process',array($this,'process_custom_course_stat'),10,7);
} // END public function __construct
add_filter('wplms_get_student_mmy_course_tabs',function($tabs){
$tabs['custom'] = 'My Custom Tab';
return $tabs;
});
add_filter('wplms_course_tab_data',function($data,$args,$course_id){
if($args['tab'] == 'custom'){
// Add content to $data
}
@MrVibe
MrVibe / test.php
Last active February 26, 2022 08:26
add_action('wp_footer',function(){
?>
<script>var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>'; </script>
<?php
});
@MrVibe
MrVibe / functions.php
Last active February 19, 2022 15:26
Digital Goods API v2 in WPLMS
add_action('wp_head',function(){
if(is_page_template('barebones.php')){
?>
<meta http-equiv="origin-trial" content="DIGITAL GOODS API V2 TOKEN">
<?php
}
});
@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 / functions.php
Created November 25, 2021 04:25
WPLMS My Courses shortcode
add_shortcode('my_courses',function($atts,$content=null){
if(empty($atts['user_id'])){
$user_id = get_current_user_id();
}else{
$user_id = $atts['user_id'];
}
$course_ids = bp_course_get_user_courses($user_id);
@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 ) {