Forked from actual-saurabh/llms-remove-notifications.php
Created
April 20, 2018 15:25
-
-
Save thomasplevy/a8973fbd7c09eb1950899ccb61e4131a to your computer and use it in GitHub Desktop.
Remove frontend notifications from LifterLMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do not copy this line | |
// Copy from under this line and paste into your child theme's functions.php | |
add_action( 'init', 'llms_turn_off_notifications', 10, 999 ); | |
add_action( 'wp_enqueue_scripts', 'llms_dequeue_notification_script', 10, 999 ); | |
if ( ! function_exists( 'llms_turn_off_notifications' ) ){ | |
function llms_turn_off_notifications(){ | |
// an array of all the notification ids in https://github.com/gocodebox/lifterlms/tree/master/includes/notifications/controllers | |
$notification_ids = array( | |
'achievement_earned', | |
'certificate_earned', | |
'course_complete', | |
'course_track_complete', | |
'enrollment', | |
'lesson_complete', | |
'section_complete', | |
'student_welcome', | |
'purchase_receipt', | |
'quiz_failed', | |
'quiz_passed', | |
'manual_payment_due', | |
'payment_retry', | |
); | |
// filter out basic notifications | |
foreach( $notification_ids as $notification ){ | |
add_filter( 'llms_notification_' . $notification . '_subscriber_options', 'llms_remove_basic_notifications', 10, 2 ); | |
} | |
} | |
} | |
if ( ! function_exists( 'llms_remove_basic_notifications' ) ){ | |
function llms_remove_basic_notifications( $subscriber_options, $type ){ | |
// only remove basic notifications, leaving emails in place | |
if ( $type != 'basic' ){ | |
return $subscriber_options | |
} | |
return array(); | |
} | |
} | |
if ( ! function_exists( 'llms_dequeue_notification_script' ) ){ | |
function llms_dequeue_notification_script(){ | |
// dequeue the notifications script | |
wp_dequeue_script( 'llms-notifications' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment