Only show first name for reviews

This topic contains 2 replies, has 2 voices, and was last updated by  Margie Mobley 8 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #376650

    Margie Mobley
    Free User
    Post count: 1

    Hi, Is it possible to only show the first name, or even better to show the first name and the Last initial, of a reviewer? Similar to how Yelp displays reviews, I’d like to not show the person’s entire name, for privacy issues.
    Right now, the avatar, first name, and last name are displayed and I’m not seeing how to restrict it to just the first name.

    Thanks in advance for any assistance on this.

    #376657

    Kor
    Moderator
    Post count: 16516

    Hi Margie,

    I’ve just spoken with our developer you would need to use the code below to achieve what you needed there. Kindly download the “Code Snippets” plugin and insert the code below.

    
    
    // Display comment author first name & last name as a reviewer.
    function gd_custom_comment_author_first_last_name( $author, $comment_ID, $comment ) {
        if ( !empty ( $comment ) && is_object( $comment ) && !empty ( $comment->user_id ) && $user = get_userdata( $comment->user_id ) ) {
            if ( !empty( $user ) && ( !empty( $user->first_name ) || !empty( $user->last_name ) ) ) {
                $author = trim( $user->first_name . ' ' . $user->last_name );
            }
        }
        return $author;
    }
    function gd_custom_plugins_loaded() {
        add_filter( 'get_comment_author', 'gd_custom_comment_author_first_last_name', 10, 3 );
    }
    add_action( 'plugins_loaded', 'gd_custom_plugins_loaded' );
    #376754

    Margie Mobley
    Free User
    Post count: 1

    Thank you! I’ll give that a try.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount