Skip to content

CommentAuthor no longer returning the name set in comment_author for comments by non-anonymous users #3197

@amxmln

Description

@amxmln

Description

Querying the name field of a comment author used to return the name set in the comment_author field in the wp_comments database, it no longer does if the comment was created by a logged in user from the WordPress Admin-Panel. Instead, it always returns the name of the user.

I understand that the node returned by CommentToCommenterConnectionEdge can either be a User or a CommentAuthor, but I think if there is a name set in comment_author querying the name field should always return that value.

This seems to be how it used to work, as we’ve been adding a generic team name to our replies to anonymous comments and until recently (probably v1.27.0) got the team name back in the query, not the name of the WordPress user.

Steps to reproduce

  1. Add a comment in the WordPress Admin Panel
  2. Change the comment_author field to 'Generic Team' by editing the comment in the Admin Panel
  3. Note the Comment’s ID
  4. In the GraphQL IDE execute the following query:
query {
  comment(id: [the ID of the comment], idType: DATABASE_ID) {
    author {
      node {
        name
      }
    }
  }
}

The expected result should be the following:

{
  "data": {
    "comment": {
      "author": {
        "node": {
          "name": "Generic Team"
        }
      }
    }
  }
}

Instead, the result is:

{
  "data": {
    "comment": {
      "author": {
        "node": {
          "name": [Your WordPress User First Name + Last Name]
        }
      }
    }
  }
}

Additional context

I’m quite new to WP GraphQL, so it might very well be that I’m missing something, but the code worked before and only recently stopped working.

Interestingly enough, comments created before the update to v1.27.0 still return the content of comment_author despite the comment having a user_id that isn’t 0.

WPGraphQL Version

1.28.1

WordPress Version

6.6.1

PHP Version

8.3.6

Additional environment details

Frontend is running via Next.js, but the issue can be reproduced in the GraphQL IDE. WordPress is run through Roots Bedrock.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

type: enhancementImprovements to existing functionality

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions