Change Comment Author Display Name

You are missing a “NOT” logical operator (!) in your if statement.
You want to say “if comment author IS NOT empty”. As of now, the function is reading that the author is not empty and defaulting to your else statement that tells it to output the author’s full name. Use the second block of code but make the following change.

Change the following:

if ( empty($comment->comment_author) ) {

to:

if ( !empty($comment->comment_author) ) {

Otherwise it looks ok to me.

Leave a Comment