• Resolved richarduk

    (@richarduk)


    How can I change if ($comment->user_id) {$user=$comment->user_id; echo $user} to output a nice name instead of the ID?

    I’ve tried using $user_identity but haven’t been able to get it to work.

    Basically if the commenter was a registered user I want to output their name on the comment.

    Any help, please? ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • vtxyzzy

    (@vtxyzzy)

    This should do what you want:

    if ($comment->user_id) {$userdata=get_userdata($comment->user_id); echo $userdata->display_name}

    Thread Starter richarduk

    (@richarduk)

    Worked like a dream! Many thanks!

    For anyone else, there’s missing semi-colon ??

    <?php if ($comment->user_id) {$userdata=get_userdata($comment->user_id); echo $userdata->display_name;}?>

    vtxyzzy

    (@vtxyzzy)

    Glad it worked! Now, please use the dropdown at top right to mark this topic ‘Resolved’.

    Thread Starter richarduk

    (@richarduk)

    Woops!

    Forgot ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘$comment->user_id Nice name instead of ID?’ is closed to new replies.