LifterLMS: Turn Off Comments on Lessons and Quizzes
Closes and hides comments on LifterLMS lessons and quizzes without affecting comments on your blog posts.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_get_student' ) ) {
return;
}
$wpide_llms_no_comment_types = array( 'lesson', 'llms_quiz' );
add_filter( 'comments_open', function ( $open, $post_id ) use ( $wpide_llms_no_comment_types ) {
return in_array( get_post_type( $post_id ), $wpide_llms_no_comment_types, true ) ? false : $open;
}, 10, 2 );
add_filter( 'get_comments_number', function ( $count, $post_id ) use ( $wpide_llms_no_comment_types ) {
return in_array( get_post_type( $post_id ), $wpide_llms_no_comment_types, true ) ? 0 : $count;
}, 10, 2 );
Notes
Remove lesson from the list if you use lesson comments for discussions.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.