• Resolved mativve

    (@mativve)


    Hi

    I have weird error. If user with lower permission than Editor (its author, contributor and subscriber) send the comment in custom post made by ACF after sending see PHP errors like this below:

    Warning: Attempt to read property "post_type" on null in <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php on line 48

    Warning: Attempt to read property "post_type" on null in <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php on line 49

    Warning: Attempt to read property "ID" on null in <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php on line 49

    Warning: Attempt to read property "post_type" on null in <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php on line 50

    Warning: Attempt to read property "ID" on null in <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php on line 50

    Warning: Cannot modify header information - headers already sent by (output started at <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php:48) in <_hosting_path_>public_html/wp-includes/pluggable.php on line 1435

    Warning: Cannot modify header information - headers already sent by (output started at <_hosting_path_>public_html/wp-content/plugins/da-reactions-premium/classes/DaReactions/Frontend.php:48) in <_hosting_path_>public_html/wp-includes/pluggable.php on line 1438

    In options of this plugin I have selected allow reaction for this custom post but disabled for comments because I don’t need this.

    Do you know any solution for this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Daniele Alessandra

    (@danielealessandra)

    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.

    Thread Starter mativve

    (@mativve)

    Thanks for fast reply! So I can add this fix in my code or wait for your update? If I should wait I can download this update somehow in Premium version? I ask about this because after buy I don’t see any account login and password to access for yours page.

    Plugin Author Daniele Alessandra

    (@danielealessandra)

    When the fix will be done, it will be available for both free and paid versions.

    I use a third party service to manage subscriptions, you should have an account on this platform: https://users.freemius.com/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Comment custom post error users with lower permission than Editor’ is closed to new replies.