Comments only first name

0.0/5
<?php
add_filter('get_comment_author', 'my_comment_author', 10, 1);

function my_comment_author( $author = '' ) {


	wp_enqueue_script( 'jquery' );

    $comment = get_comment( $comment_ID );

    if ( !empty($comment->comment_author) ) {
        if (!empty($comment->user_id)){
            $user=get_userdata($comment->user_id);
            $author=$user->first_name; // this is the actual line you want to change
        } else {
            $author = __('Anonymous');
        }
    } else {
        $author = $comment->comment_author;
    }

    return $author;
}

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet was fetched automatically from WPDistro.cz projects.

Author

Tags

This snippet is untagged