Skip to content

How to filter nested ACF fields? #207

Closed Answered by roccopung
roccopung asked this question in Q&A
Discussion options

You must be logged in to vote

SOLVED: the solution was to create a small Wordpress plugin that would add an input to the UserUpdate mutation, check if the input would match my custom post type, and then update the luoghiVisitati using a simple update_field from ACF. Here's the plugin's code:

<?php

add_action('graphql_register_types', function () {
    register_graphql_field('UpdateUserInput', 'luogoId', [
        'type' => 'ID',
        'description' => __('ID of the luogo to add', 'wp-graphql')
    ]);
});

add_action('graphql_user_object_mutation_update_additional_data', function ($user_id, $input, $mutation_name, $context, $info) {
    if (isset($input['luogoId'])) {
        // Sanitize and validate the input
    …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by roccopung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant