question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Advanced Custom Fields - Type "User" not retrieved properly in gatsby-source-wordpress

See original GitHub issue

Preliminary Checks

Description

The issues happened when I use the Advanced Custom Fields (ACF) with GraphQL in wordpress. image

If the ACF Fields type is USER, it is able to retrieve in the GraphQL in wordpress as the screenshot shown below. image

However, when it reach to gatsby source, the graphql cannot get the value of the user. image

This issue only occurred whenever the ACF field type is USER. If the field type is other (eg.: Text), the data can be retrieved correctly.

Reproduction Link

can’t share the repo sorry

Steps to Reproduce

  1. Install plugins in wordpress and set up wordpress as source with gatsby-source-wordpress
  2. Create a new field group on pages with ACF and add a “User” field with type “USER” that links to a page
  3. Run http://localhost:8000/__graphql in the fresh Gastby site and run the query for the user field.

Expected Result

The user field is correctly reflected in the gatsby-source-wordpress GraphQL like the Wordpress GraphqQL.

Actual Result

The user field returns null in the gatsby-source-wordpress GraphQL

Environment

System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 14.17.1 - C:\Program Files\nodejs\node.EXE
    npm: 7.19.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 94.0.4606.81
    Edge: Spartan (44.19041.1266.0), Chromium (94.0.992.50)
  npmPackages:
    gatsby: ^3.7.0 => 3.9.1
    gatsby-awesome-pagination: ^0.3.8 => 0.3.8
    gatsby-plugin-advanced-sitemap: ^2.0.0 => 2.0.0
    gatsby-plugin-emotion: ^6.9.0 => 6.9.0
    gatsby-plugin-google-tagmanager: ^3.12.0 => 3.12.0
    gatsby-plugin-image: ^1.12.0 => 1.12.0
    gatsby-plugin-layout: ^2.7.0 => 2.9.0
    gatsby-plugin-postcss: ^4.9.0 => 4.9.0
    gatsby-plugin-react-helmet: ^4.12.0 => 4.12.0
    gatsby-plugin-robots-txt: ^1.6.10 => 1.6.10
    gatsby-plugin-sharp: ^3.12.0 => 3.12.0
    gatsby-source-graphql: ^3.9.0 => 3.9.0
    gatsby-source-shopify: ^4.7.0 => 4.7.1
    gatsby-source-wordpress: ^5.7.0 => 5.9.1
    gatsby-transformer-sharp: ^3.12.0 => 3.12.0
  npmGlobalPackages:
    gatsby-cli: 3.13.0

Config Flags

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
chieyang96commented, Nov 12, 2021

@awelles sorry for the late reply but I’ve used the solution provided and it seems working as what I wish for. Thanks a lot!

1reaction
awellescommented, Oct 27, 2021

@chieyang96 have a look here. When querying from gatsby you’re unauthorized w/ wordpress and so lack the ‘list_users’ capability. This blocks the user’s from showing. You can add PHP to your wordpress install to bypass this:

https://www.wpgraphql.com/recipes/make-all-users-public/

Side note: WPGraphql allows you to see Users when unauthorized, just not ACF User fields. Which doesn’t seem quite right… Something to bring up with ‘WPGraphQl for ACF’ devs perhaps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Custom Fields are detected on normal WP Post but ...
In my project I have multiple content types: default ones: posts and pages programs (custom content type created with register_post_type) ...
Read more >
Known Issues - ACF
Welcome to the known issues guide for the Advanced Custom Fields plugin. This guide contains information and solutions for common problems found in...
Read more >
How to use gatsby-source-wordpress and add ACF to Menu's ...
Is it possible to query ACF added to Menu's and Menu Items? I was struggling with this specific use case of querying data...
Read more >
gatsby-source-wordpress
Any new entity should be pulled as long as the IDs are correct. ACF Entities (Advanced Custom Fields); Custom Post Types (any type...
Read more >
Using New Gatsby Source WordPress Plugin - CSS-Tricks
This article is not a step-by-step guide on how to use Gatsby Source ... and one that uses WordPress with the Advanced Custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found