bryan alman
asked 7 years ago

Notice: Trying to get property of non-object in /home/user/public_html/wp-content/plugins/dw-question-answer/inc/roles.php on line 351

I got this error when I update my wordpress seo plugin and install mycred.

How to fix this error?

1 Answers
Allen
answered 7 years ago

@bryan alman : hi this is an conflict between mycred and DWQA. In file dw-question-answer/inc/roles.php, go to line 348 then replace the function allow_user_view_their_draft_post with :

function allow_user_view_their_draft_post( $all_caps, $caps, $name, $user ) {
        if ( is_user_logged_in() ) {
            global $wp_query, $current_user;
            if( isset( $wp_query->is_single ) ) {
                if ( $wp_query->is_single && $wp_query->query_vars['post_type'] == 'dwqa-question' && $name[0] == 'edit_post' ) {
                    if ( isset( $name[2] ) ) {
                        $post_id = $name[2];
                        $author = get_post_field( 'post_author', $post_id );
                        if ( $author == $current_user->ID ) {
                            foreach ( $caps as $cap ) {
                                $all_caps[$cap] = true;
                            }
                        }
                    }
                }
            }
        }
        return $all_caps;
    }
postik
replied 7 years ago

@nobita: This solve the error. Thank you so much!

Powered by DW Question & Answer Pro