New Landing How can we help? Themeforest Theme Support Neighborhood Change author and translate comments

Viewing 10 posts - 1 through 10 (of 10 total)
  • #92618
    lobbybros
    Member
    Post count: 52

    Hello

    I have two questions relating to comments:
    1) I would like to change for the comment author to show a First Name and not the Username of registered users;
    2) I cannot seem to translate “Your comment is awaiting moderation”, even through the po file.

    Any ideas?
    Thks!
    Claudia

    #93021
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,

    1-Please insert given below code at functions.php of child theme at end of file.

    add_filter('get_comment_author_link', 'sf_comment_first_name');
    function sf_comment_first_name($author) {
        global $comment;
        if (!empty($comment->user_id)){
            $user=get_userdata($comment->user_id);
            $author=$user->display_name;    
        }
    
        return '<a>comment_author_url.'" >'.$author.'</a>';
    }
    
    

    2- I have this string in po file at latest version 1.80 of theme.

    Thanks 🙂
    With Best Regards
    Swift Ideas

    #93701
    lobbybros
    Member
    Post count: 52

    Hi Mohammed!
    Thks for yr reply.

    I tried yr code, but it gives me a syntax error in the “return” line; also, when I eliminated the url and just used return $author, it still was showing the username and not first name.
    However, I tweaked the code a bit and came up with this:

    add_filter('get_comment_author_link', 'sf_comment_first_name');
    function sf_comment_first_name($author) {
        global $comment;
        if (!empty($comment->user_id)){
            $user=get_userdata($comment->user_id);
            $author=$user->user_firstname;    
        }
    
        return $author;
    }
    

    which works just fine! So thanks for your help!

    Just one more question…can I get this to do the same thing for my product reviews?

    Thks again,
    Claudia

    #93742
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please try to use this code only-:
    add_filter('comment_author', 'sf_comment_first_name');
    Thanks

    #93781
    lobbybros
    Member
    Post count: 52

    Unfortunately this works on review but not on the regular comments..

    #93793
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Why did you remove last action ? Please insert this code also.
    add_filter('get_comment_author_link', 'sf_comment_first_name');
    Thanks

    #93987
    lobbybros
    Member
    Post count: 52

    Sorry, didn’t understand that it needed to be used in addition to the other filter!
    All works now, thks!

    As regards the translation of “Your comment is awaiting moderation”, I have found and modified the .po file in the new version of neighborhood. However, it still is showing in English instead of in Italian (while the other strings I translated all work fine). Any suggestions?

    Kind regards
    Claudia

    #93992
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You can change these string directly at functions.php.
    Thanks

    #94097
    lobbybros
    Member
    Post count: 52

    Great! Thanks 🙂

    #94104
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    No problem 🙂 Glad Mohammad could help you

    – Kyle

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register