Home Forums ACF PRO Access to relationship picker in admin


Access to relationship picker in admin

  • Just very generally – I’m trying to do the following at the post level in admin:

    On change of relationship picker:
    1. get meta data of that post
    2. Populate the input value of another field with meta data from step 1

    The idea is that we would be providing suggested copy for those user to use.

    Is it possible to access the object of that post, like we do in the templates? Or do I need to grab the ID (I see it in the data attribute) and ajax in the post?


  • Yes, I can give you some direction, but I can’t give you details on your exact case. Honestly, there’s not a lot of information available on doing what you want to do. I have been working on a project that does similar things.

    You can see an example of what I’m doing here:

    This script extends the acf.ajax script. In it I have created change events that fire when certain fields have been changes. Two of the functions do AJAX requests to to get information that’s used to populate other fields. The functions are _para_tax_change and _para_meta_key_change.

    Getting values from every type of field is slightly different, I have not worked with a relationship field, which is why a said I can’t give specifics. What I do is just start adding alert(something); in the script to see what I can figure out and go from there.

    You can see the PHP side of the AJAX requests in this file You can see where the filters are added in the __construct function and the related functions that are called.

    This file contains an example of how I enqueue the script

    I realize that’s a long way from an perfect answer but I hope it helps.

  • I really appreciate the direction, thanks for your help!

  • Thanks again, I was able to use your on change code to understand how the relationship behaved. I also used and to pass the ID: (‘.values input’).val() in order to pull in the acf meta from the selected post.

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

The topic ‘Access to relationship picker in admin’ is closed to new replies.