• Resolved quichotte

    (@quichotte)


    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).

Viewing 7 replies - 1 through 7 (of 7 total)
  • Every decent theme does it: if the user is logged in, they don’t even show the name, email, url fields…

    Thread Starter quichotte

    (@quichotte)

    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.

    Thread Starter quichotte

    (@quichotte)

    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 ??

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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;
    }

    Thread Starter quichotte

    (@quichotte)

    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….

    Thread Starter quichotte

    (@quichotte)

    would I better put that code in comments.php or put it in function.php

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘If comment author has id print display name’ is closed to new replies.