From 6437d3d5cfee9a7507065d307421bbd06bd3f065 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 9 Jan 2024 09:04:17 +0100 Subject: [PATCH] better user handling in post transformer --- includes/transformer/class-post.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/transformer/class-post.php b/includes/transformer/class-post.php index 54ae8a7bd..3a1fb0b90 100644 --- a/includes/transformer/class-post.php +++ b/includes/transformer/class-post.php @@ -116,12 +116,19 @@ public function get_url() { * @return string The User-URL. */ protected function get_attributed_to() { + $blog_user = new Blog_User(); + if ( is_single_user() ) { - $user = new Blog_User(); + return $blog_user->get_url(); + } + + $user = Users::get_by_id( $this->wp_object->post_author ); + + if ( $user && ! is_wp_error( $user ) ) { return $user->get_url(); } - return Users::get_by_id( $this->wp_object->post_author )->get_url(); + return $blog_user->get_url(); } /**