focuspro
@focuspro

Как решить ошибку Trying to get property of non-object?

Notice: Trying to get property of non-object in /var/www/admin/data/www/test.com/wp-content/themes/bd/inc/blt-functions.php on line 638

635          if(!function_exists('blt_get_comment')){
636		    function blt_get_comment($comment, $args, $depth){
637
638			$author_comment_id = get_user_by('email', get_comment_author_email())->ID;
639			$comment_score = get_comment_meta( get_comment_ID(), 'blt_score', true );
640			if(empty($comment_score)){
641				$comment_score = 0;
642				}
643				  $GLOBALS['comment'] = $comment;
644				  extract($args, EXTR_SKIP);
645
646				 $args['style'] = isset($args['style']) ? $args['style'] : 'li';
  • Вопрос задан
  • 1490 просмотров
Решения вопроса 1
@Quieteroks
php программист
Простая проверка вместо:
$author_comment_id = get_user_by('email', get_comment_author_email())->ID;

Нужно просто проверить:
$author_comment = get_user_by('email', get_comment_author_email());
if (empty($author_comment)) {
    return ...;
}
$author_comment_id = $author_comment->ID;
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы