Comment custom post error users with lower permission than Editor

Hello, thank you for using my plugin, and also for reporting this bug.

The code that generates error is the following:

public function addButtonsToComment( $comment_text ) {
    global $post;
    $options = Options::getInstance( 'general' );
    $globally_enabled = $options->getOption( 'post_type_' . $post->post_type . '_comments' ) === 'on';
    $locally_enabled  = $options->getOption( 'post_type_' . $post->post_type . '_enable_comments_' . $post->ID ) === 'on';
    $locally_disabled = $options->getOption( 'post_type_' . $post->post_type . '_disable_comments_' . $post->ID ) === 'on';

This function should only be executed when WordPress is rendering a single post page so that the variable $post exists. Maybe in your case the comments related hook is executed elsewhere.

A simple solution that you may implement right now is to exit from the function if there is no $post, before trying to access its properties. Someting like this:

public function addButtonsToComment( $comment_text ) {
    global $post;
    if (!isset($post)) {
        return; /// Exit the function
    }
    $options = Options::getInstance( 'general' );
    $globally_enabled = $options->getOption( 'post_type_' . $post->post_type . '_comments' ) === 'on';
    $locally_enabled  = $options->getOption( 'post_type_' . $post->post_type . '_enable_comments_' . $post->ID ) === 'on';
    $locally_disabled = $options->getOption( 'post_type_' . $post->post_type . '_disable_comments_' . $post->ID ) === 'on';

The function is located inside <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php at row 45.

I will publish this fix as soon as possible.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer