# LifterLMS: Turn Off Comments on Lessons and Quizzes

> Closes and hides comments on LifterLMS lessons and quizzes without affecting comments on your blog posts.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: lifterlms, comments, courses
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/lifterlms-close-comments-on-lessons/

## Code

```php
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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LifterLMS: Turn Off Comments on Lessons and Quizzes" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
