I am trying to get my forms to work with the new relationships and am having difficulty on one of them. The form is meant to allow a user to post a link to a product review to be associated with a particular product listing, and it is set to have a status "Pending" upon submission. Here is the relevant code on the form:
[credform class='cred-form cred-keep-original']
<div class="hidden">[cred_field field='@product-listing_product-review-ext.parent' urlparam='productid' class='hidden' output='bootstrap']</div>
[cred_field field='form_submit' value='Submit' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']
[/credform]
When loading the form, it appears to be correctly selecting the parent product because when I un-hide the div section I can see that it is selected. Upon form submission, the following code is run:
add_filter('cred_success_redirect_328', 'custom_redirect_for_form_with_id_328', 10, 3);
function custom_redirect_for_form_with_id_328( $url, $post_id, $form_data )
{
$relationship_to_query = "product-listing_product-review-ext";
$role = "parent";
$related_post = toolset_get_related_post( $post_id, $relationship_to_query, $role);
$newurl = get_permalink($related_post);
return $newurl;
}
I was expecting the post to be added and to be redirected to the parent product listing. However, the toolset_get_related_post is returning 0 instead of the expected parent post type ID. When going into the database, I do not see any records being written to the toolset_associations table. In the WordPress back end, I can see the review as being added with pending status but there is no association with the parent product.
Attached are screenshots from the toolset_relationships table so you can see the slug being used. This relationship is set as a one-to-many with the product listing being able to take infinite reviews.
Thanks for any help. Feeling stuck.
- Aaron