Ensure a user exists in get_comment_author().

props azaozz.
see #24084.


git-svn-id: https://develop.svn.wordpress.org/trunk@25136 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-08-27 13:16:34 +00:00
parent 328117ffbf
commit 2b280c5761
1 changed files with 7 additions and 7 deletions

View File

@ -22,17 +22,17 @@
*/ */
function get_comment_author( $comment_ID = 0 ) { function get_comment_author( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID ); $comment = get_comment( $comment_ID );
if ( empty($comment->comment_author) ) {
if (!empty($comment->user_id)){ if ( empty( $comment->comment_author ) ) {
$user=get_userdata($comment->user_id); if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
$author=$user->user_login; $author = $user->display_name;
} else { else
$author = __('Anonymous'); $author = __('Anonymous');
}
} else { } else {
$author = $comment->comment_author; $author = $comment->comment_author;
} }
return apply_filters('get_comment_author', $author);
return apply_filters( 'get_comment_author', $author );
} }
/** /**