Problem:
When using the toolset_association_created hook to retrieve a relationship field value from the intermediary post, the custom field returned an empty value, even though the value was confirmed to exist in the database. The field was stored on the intermediary post, and get_post_meta() was being called inside the hook, but it returned blank.
Solution:
The issue was caused by timing. At the moment toolset_association_created fires, the intermediary post meta may not yet be fully saved and available for retrieval.
To resolve this, the meta retrieval was delayed until after Toolset completed saving the relationship. This was achieved by scheduling a secondary action using wp_schedule_single_event() and retrieving the field value in a later hook.
Confirmed the intermediary post exists and has the expected post type and status.
Verified the correct meta key (wpcf-donor-scholar-relationship-status) is stored on the intermediary post.
Ensured the field is indeed saved on the intermediary (relationship fields are not stored on parent/child posts).
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 1 reply, has 1 voice.
Last updated by 1 month ago.
Assisted by: Christopher Amirian.