From 03792b2e62157fcbf28919a11568feccb0f1599f Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 19 Nov 2008 06:58:44 +0000 Subject: [PATCH] Handle blank display_name for commenters. props mrmist. fixes #7494 git-svn-id: https://develop.svn.wordpress.org/trunk@9781 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-comments-post.php | 2 ++ wp-includes/comment-template.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-comments-post.php b/wp-comments-post.php index 0fc2317544..64cc8e3295 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -40,6 +40,8 @@ $comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : // If the user is logged in $user = wp_get_current_user(); if ( $user->ID ) { + if ( empty( $user->display_name ) ) + $user->display_name=$user->user_login; $comment_author = $wpdb->escape($user->display_name); $comment_author_email = $wpdb->escape($user->user_email); $comment_author_url = $wpdb->escape($user->user_url); diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index fba653c0b4..75cf57c229 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -21,10 +21,16 @@ */ function get_comment_author() { global $comment; - if ( empty($comment->comment_author) ) - $author = __('Anonymous'); - else + if ( empty($comment->comment_author) ) { + if (!empty($comment->user_id)){ + $user=get_userdata($comment->user_id); + $author=$user->user_login; + } else { + $author = __('Anonymous'); + } + } else { $author = $comment->comment_author; + } return apply_filters('get_comment_author', $author); }