Hi Toolset,
I've got a Form integrated into a CPT (showcasing locations) Within the form the enduser needs to select a post while going through a signup process.
I'd like the options within the 'Post Reference' cred_field to be filtered by the one-to-many post relationship. I'd like the posts that already have a relationship to the locational page to be the only options within the 'Post Reference' cred_field.
Thanks in advance!
It's natively not possible.
The Relationships Fields let you filter possibly to relate posts by the current user (authorship) or all posts of that type. This is the same for Post Reference Fields, you can only filter by authorship of the current user.
You'd have to submit a Feature Request at https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/, asking for a way to add your own custom Query to those input Fields, so you could (for example) let a View populate the Field, or a Custom Code hooked to a filter in our codebase.
Currently, there is no other way to achieve this, and it will also be challenging with Custom Code since all those filters we have (which are undocumented) should return either a post author ID or the keyword '$current'. Hence, they cannot return a post-relationship or other data for the query.
I'm afraid like this you can not limit the PRF (Post Reference Field), currently.
You'd have to populate a Generic Checkboxes Field, for example, populated by a View returning the desired Posts data in a valid JSON format.
Then, with a cred_save_data() snippet you could grab the values (let's say post ID's) from that field, and update the Post's PRF Field with that value using the Toolset API, which can be used also to either connect, get connected, or disconnect posts.
For updating PRF fields (which are Custom fields), you'd still use the above API (toolset_connect_posts()).
Here is the related Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data