From 7c85d9ab155254b63c3b2144dc77889f7502916f Mon Sep 17 00:00:00 2001 From: Lee Maguire Date: Thu, 12 Dec 2024 17:15:10 +0000 Subject: [PATCH] Don't display a byline if the page has an invalid author Posts having post_author ids that refer to deleted users cause problems - even if co-authors is populated. In the short term, don't attempt to resolve the author, and independently find posts with a) deleted authors b) populated co-authors and switch them to be user 0 --- lib/byline.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/byline.php b/lib/byline.php index 4d18062..bc608ad 100644 --- a/lib/byline.php +++ b/lib/byline.php @@ -4,11 +4,17 @@ function gds_byline() { ?> - Posted by: - Posted by: ID ); + $tmp_user = get_user_by('id', $author_id ); + if (empty($tmp_user->user_login)) { + echo "Deleted user $tmp_author_id"; + error_log("{$post->ID} has deleted user $tmp_author_id", 0); } else { - ?>