【问题标题】:Change Review Display Name on Woo-commerce Store在 Woo-commerce Store 上更改评论显示名称
【发布时间】:2017-03-07 09:51:19
【问题描述】:

我希望能够更改显示在 woocommerce 平台上的评论中的名称。我找到了一些信息,但我是 WordPress 新手,似乎没有人知道答案。这是一个链接,我可以找到一些东西,但没有安装细节。

我需要知道在哪里以及如何更改它。谢谢。

这是我找到的链接。

https://silicondales.com/tutorials/woocommerce-tutorials/woocommerce-change-review-author-display-name-username/

我添加了一个名为 Username Changer 的插件,它可以让我更改帐户的用户名,但它不会更新评论用户名。

这是截至目前(2017 年 3 月 6 日)的一些图片

如何使用已编辑的用户名配置用户的快照:

【问题讨论】:

    标签: wordpress woocommerce review


    【解决方案1】:

    好的,我想通了。如果您没有子主题,则需要将代码发布到 functions.php 文件中。建议您设置一个,但我还没有,我只是想先解决这个问题。这是您需要的快照。

    将以下文本块添加到底部或外观 > 编辑器中的 custom-functions.php 或 functions.php 页面

    add_filter('get_comment_author', 'my_comment_author', 10, 1);
    function my_comment_author( $author = '' ) {
    // Get the comment ID from WP_Query
    $comment = get_comment( $comment_ID );
    if (!empty($comment->comment_author) ) {
    if($comment->user_id > 0){
    $user=get_userdata($comment->user_id);
    $author=$user->first_name.' '.substr($user->last_name,0,1).'.'; // this is the actual line you want to change
    } else {
    $author = __('Anonymous');
    }
    } else {
    $author = $comment->comment_author;
    }
    
    return $author;
    }
    

    确保更新用户信息。

    Missing Sections from the Original Question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-19
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      相关资源
      最近更新 更多