I’m using a bidirectional relationship called special-offers-to-listings, where:
From: a Special Offer post type
To: a Business Listing post type
On the Special Offer edit screen, the user selects a connected Business Listing.
I’m running some custom logic (sending emails and saving coupon redemptions) immediately after the post is saved.
However, when I call:
MB_Relationships_API::get_connected([
'id' => 'special-offers-to-listings',
'from' => $post_id,
]);
inside a save_post or even an rwmb_after_save_post hook, it sometimes returns an empty array, even though the relationship clearly exists once I reload the post.
At what point in the save process are relationships written to the mb_relationships table?
Is there a specific hook (e.g., rwmb_after_save_field, rwmb_relationships_after_save, etc.) that guarantees MB_Relationships_API::get_connected() will return the correct results right after saving?
We’re also testing rwmb_meta( 'special-offers-to-listings', ['type'=>'relationship'], $offer_id ) as a fallback — can you confirm whether that retrieves relationship data earlier than MB_Relationships_API::get_connected() during the post save process?