quichotte
Member
Posted 3 years ago #
I've been searching high and low for this;
On my website only registered authors can comment...
How do I fix comment.php that way that when an author makes a comment his/her current display name (in the user table) is displayed instead of what is put in the comment table at the time of when the comment was made.
In short: If the comment author has an id (registered), then print the current 'display_name' (from the user table) instead of comment_author (comment table).
Every decent theme does it: if the user is logged in, they don't even show the name, email, url fields...
quichotte
Member
Posted 3 years ago #
thats not what I mean I am afraid:
"XXX" made comemnt on..."
I want XXX to reflect/read 'display_name' (from the user table) instead of comment_author (comment table)
Yes. It shows the display name.
quichotte
Member
Posted 3 years ago #
I want to show the current display name form user_table, not the one the author used at the time he wrote the comment and which was put in the comment_table.
something like:
if ( $comment->user_id > 0 ) {
$user = get_userdata($comment->user_id);
print ... etc
If that is what you mean, please provide that code. But I think I am not making myself clear or you read too fast :)
Ah. Yeah, you can't do that.
Well, okay, you CAN, you just really shouldn't. Keeping your user comments consistent is less confusing to your readers.
But your code was basically correct:
if ($comment->user_id) {
$user=get_userdata($comment->user_id);
echo $user->user_nicename;
}
quichotte
Member
Posted 3 years ago #
Ah, someone who got my problem :) Thanx.
Why shouldnt I do that btw? I like to display that name and link it to it's author page itself....
quichotte
Member
Posted 3 years ago #
would I better put that code in comments.php or put it in function.php