Parent comment's author display_name

Parent comments author nameI found this code and would like to modify it as follows: if someone changes the display_nam

Parent comment's author name

I found this code and would like to modify it as follows: if someone changes the display_name, the name in the comments should also change. I was able to achieve this with the following code in the comments:

$usermeta = get_userdata($comment->user_id);

<?php echo $usermeta->display_name?>

However, I don't know how to change the code below to show display_name here as well.

if( $comment->comment_parent )
comment_author( $comment->comment_parent );

I appreciate any help.

Parent comment's author name

I found this code and would like to modify it as follows: if someone changes the display_name, the name in the comments should also change. I was able to achieve this with the following code in the comments:

$usermeta = get_userdata($comment->user_id);

<?php echo $usermeta->display_name?>

However, I don't know how to change the code below to show display_name here as well.

if( $comment->comment_parent )
comment_author( $comment->comment_parent );

I appreciate any help.

Share Improve this question asked Jul 14, 2020 at 19:16 Robert HeroldRobert Herold 12 bronze badges 1
  • You want to show the display_name for the parent comment instead of the author name? – mozboz Commented Jul 14, 2020 at 21:09
Add a comment  | 

2 Answers 2

Reset to default 0

So to do the same thing but for the parent comment this should do it. This is untested but does the same thing as your first case, but with the parent comment object instead of the current comment.

if( $comment->comment_parent ) {
    $parentComment = get_comment($comment->parent);
    $usermeta = get_userdata($parentComment->user_id);
    echo $usermeta->display_name ; 
}

Does that do it?

Oh, I got it!

if( $comment->comment_parent ) {
    $parent_ID = $comment->comment_parent;
    $parent_comment = get_comment($parent_ID);
    $parent_usermeta = get_userdata($parent_comment->user_id);
    echo $parent_usermeta->display_name; }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742256729a4410157.html

相关推荐

  • Parent comment&#39;s author display_name

    Parent comments author nameI found this code and would like to modify it as follows: if someone changes the display_nam

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信