Remove surname from comments

Change of this field: .woocommerce-review__author

/**
 * Change the comment name to show only Firstname.
 */
function twstudio_my_comment_author( $author = '' ) {

	$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, 0 ) . '';
		} else {
			$author = __( 'No name' );
		}
	}

	return $author;
}

add_filter( 'get_comment_author', 'twstudio_my_comment_author', 10, 1 );

Leave a Reply

Your email address will not be published. Required fields are marked *