Support

Account

Home Forums General Issues Use value from field in another group

Helping

Use value from field in another group

  • Hi,

    I’ve searched the forum and could not find an answer for my problem.
    What i’m trying to do:
    I have two CPUs: relations and donations with each off them field groups.
    I would like the field NAME in the field group Donations to be a select field where all values off the field Last Name in the field group relations are shown as choices.
    Is this possible? Can someone give me a clue where to start?

    Regards, Pip

  • I’ve found this and it works fine. The field donations is a Post Object field and in functions.php I’ve added this code:

    <?php

    function my_post_object_result( $title, $post, $field, $post_id ) {

    // load a custom field from this $object and show it in the $result
    $page_views = get_field(‘achternaam’, $post->ID);

    // append to title
    $title .= ‘ [‘ . $page_views . ‘]’;

    // return
    return $title;

    }

    // filter for every field
    add_filter(‘acf/fields/post_object/result’, ‘my_post_object_result’, 10, 4);

    ?>

    One more question though.. when I fill in the field Donation I can only search on post_id, not on the custom field.

    Any ideas?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Use value from field in another group’ is closed to new replies.