Last active
September 5, 2019 08:49
-
-
Save actual-saurabh/9826484ca095e3f3c0430ca59ad853b3 to your computer and use it in GitHub Desktop.
Remove frontend notifications from LifterLMS
This file contains hidden or 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
@RifleFish you can remove the trigger ids that you wish to keep the notifications for, from the list in lines 12-26.