Handle blank display_name for commenters. props mrmist. fixes #7494

git-svn-id: http://svn.automattic.com/wordpress/trunk@9781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2008-11-19 06:58:44 +00:00
parent e4c2127e20
commit 93bc9521cd
2 changed files with 11 additions and 3 deletions

View File

@ -40,6 +40,8 @@ $comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) :
// If the user is logged in // If the user is logged in
$user = wp_get_current_user(); $user = wp_get_current_user();
if ( $user->ID ) { if ( $user->ID ) {
if ( empty( $user->display_name ) )
$user->display_name=$user->user_login;
$comment_author = $wpdb->escape($user->display_name); $comment_author = $wpdb->escape($user->display_name);
$comment_author_email = $wpdb->escape($user->user_email); $comment_author_email = $wpdb->escape($user->user_email);
$comment_author_url = $wpdb->escape($user->user_url); $comment_author_url = $wpdb->escape($user->user_url);

View File

@ -21,10 +21,16 @@
*/ */
function get_comment_author() { function get_comment_author() {
global $comment; global $comment;
if ( empty($comment->comment_author) ) if ( empty($comment->comment_author) ) {
if (!empty($comment->user_id)){
$user=get_userdata($comment->user_id);
$author=$user->user_login;
} 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);
} }