New Landing How can we help? Themeforest Theme Support Flexform change admin display name for all existing comments

Viewing 6 posts - 1 through 6 (of 6 total)
  • Posted in: Flexform
  • #102451
    mrjWells
    Member
    Post count: 137

    I think this is actually a wordpress question, but hours of searching the web has not helped me find an answer. So, thought I would ask my favorite experts!

    Here’s my question: Is there a way to change the admin display name for existing comments?

    I know I can edit each comment by hand, but there are thousands of them.
    I also know that I can change the display name for future comments in the “edit users” section.

    But my goal is to change the display name on all existing admin comments. Can this be done?

    #102517
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please insert this code at functions.php :-

    add_filter('get_comment_author', 'wpse31694_comment_author_display_name');
    function wpse31694_comment_author_display_name($author) {
        global $comment;
        if (!empty($comment->user_id)){
            $user=get_userdata($comment->user_id);
            $author=$user->display_name;
             $author = ( $author == 'admin' ) ? 'myNewName' :  $author;
        }
    
        return $author;
    }

    Thanks ๐Ÿ™‚
    With Best Regards
    Mohammad

    #102654
    mrjWells
    Member
    Post count: 137

    Wow, looks good Mohammad.

    So, just to be sure I do this correctly, do I put the name I want to display where it says ‘myNewName’?

    And do I need to put the old display name or my username anywhere in the code?

    The current display name is ‘Jonathan – Advanced Life Skills’ and I just want it to say ‘Jonathan’, my username is ‘jWells’

    #102733
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Yes, you can replace myNewName with Jonathan to make change as you desire.
    Thanks

    #102805
    mrjWells
    Member
    Post count: 137

    This worked perfectly! Thank so much Mohammad, very appreciated.

    #102888
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You most welcome. I’m glad that issue resolved.
    Thanks ๐Ÿ™‚
    With Best Regards
    Mohammad

Viewing 6 posts - 1 through 6 (of 6 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