Home › Toolset Professional Support › [Resolved] Best way to "match" a review with a muay thai gym using Gravity Forms
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.
Our next available supporter will start replying to tickets in about 1.10 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Tagged: Views plugin
This topic contains 9 replies, has 2 voices.
Last updated by simonV-3 3 years, 8 months ago.
Assisted by: Shane.
Tell us what you are trying to do? On every Muay Thai Gym (hidden link) I have a Gravity Form, where customers can leave a review.
As each review is for the specific custom post type, where they are actually, I like to perge / match it together. Once I have the review, I will show the reviews on each one.
What is the best approach to do it? I know there might be a way to create a relationship, but maybe another way to do it. I was thinking to get the actual post id from the custom post type and add this number in a hidden field in the review form, respectively as a field in the custom post type.
If this is a way, how do I get easy and with a short code the custom post id?
Is there any documentation that you are following? https://toolset.com/forums/topic/gravity-forms-relationship-issue/
Is there a similar example that we can see? hidden link
What is the link to your site?
Hi Simon,
Thank you for getting in touch. Since you are using gravity forms to do the reviews the suggestion of having the hidden field with the ID of the current post.
To get the ID you can use this shortcode [wpv-post-id]. Assuming here that you will be creating a matching custom field on the backend so that the ID information can be stored on the comment itself.
Once this has been done you are then able to use our Blocks plugin and on your page template add a view with the query filter for the custom field. You will then need to set this custom field filter to "Shortcode Attribute" instead of "Constant". Let say you've set the shortcode attribute value to "ids", you will need to use this attribute to pass the ID of the current post into the view.
Using the view's shortcode insert it into your template like my example below
[wpv-view name='my-view' ids='[wpv-post-id]']
Where my-view is the slug of your view that is listing out the comments. Also as you can see i'm passing the ID of the current post into the view.
Please let me know if this helps.
Thanks,
Shane
Dear Shane
I am getting close to this...
Please have a look here: hidden link
But it shows me a bit too much - plus some chars in the end ']
If You can help me to get this... once I have all information I need, I will do some design stuff. It seems as it is not working with the id. Maybe I used the wrong format for the id in my custom post type.
I expect to see:
"Great experience in the Gym from a Swiss owner
Great experience in the Gym from a Swiss owner, Great experience in the Gym from a Swiss owner
Simon Vetterli
Excellent"
Instead - it shows me all reviews, plus the body part of the actual post.
I have now a view with the followed parts:
Search and pagination:
[wpv-filter-start hide="false"] [wpv-filter-controls] [wpv-post-title output="sanitize"] [wpv-post-body view_template="None"] [types field='author-first-name'][/types] [types field='author-last-name'][/types] [types field='rating'][/types] [/wpv-filter-controls] [wpv-filter-end]
Loop editor:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [wpv-post-body view_template="My Reviews View - slide"] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]We don't have any review yet for this Gym[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Template:
[wpv-post-link] [wpv-post-title output="sanitize"] [wpv-post-body view_template="None"] [types field='author-first-name'][/types]
Please be aware, that I am not using WordPress Blocks (I am not that friendly with it - yet)...
Dear Shane
I think I need to do something like this: https://toolset.com/forums/topic/post-relationship-query-with-toolset_get_related_posts/
What I like to achieve is, to create my own short code, where I am giving the fields I need.
something like this as an example: [showmyreview field="lastname"] - I have then my own grid builder (from the theme).
To do this way, I need to have the followed logic:
1. Find the post ID (from the review), where the specific ID field is the parent post ID
2. Once I have this post ID, I should be able to get the field values
Or what You think? Do You have an example code (for php) I might be able to use?
Regards,
Simon
Hi Simon,
Would you mind allowing me to have admin access to the site so that I can have a look at this one in a bit more detail for you ?
The thread below is related to a post relationship.
https://toolset.com/forums/topic/post-relationship-query-with-toolset_get_related_posts/
However in your case you are using gravity forms to store the comments so the post relationships won't apply here.
I need some clarification on a few things.
1. Find the post ID (from the review), where the specific ID field is the parent post ID
Is the review being created on the same page as the parent ? Meaning is the gravity form for the review on the same page that is being reviewed?
2. Once I have this post ID, I should be able to get the field values
In your previous post you mentioned about storing the current post's id in a hidden field however as long as the form is on the same page you can get the id of the current post using the shortcode [wpv-post-id]
Once the ID is stored on the post itself we can filter for that ID using my comments in the posts below.
https://toolset.com/forums/topic/best-way-to-match-a-review-with-a-muay-thai-gym-using-gravity-forms/#post-1962819
I've enabled the private fields for your next response so that I can have a quick look at the site to see what you've already done.
Thanks,
Shane
Hi Simon,
Given the current scenario i'm not sure why the gravity forms hook isn't firing.
However I see where you are already storing the post ID on the post, so we can use this to get the correct posts. Given that i'm not able to debug why the gravity forms hook isn't firing on their form.
I attempted to locate the template where you've inserted the view, however all you need to do now is insert your view like this below.
[wpv-view name='my-reviews-view' ids='[wpv-post-id]']
This should let your view filter for the correct posts.
If this doesn't work then can you point me to the template file that is being used to display the Muay Thai Gyms
Thanks,
Shane
Dear Shane
It does show something, but seems not to working as I expect. If You check the hole source code from the review part.
I am also not sure if I use the correct format for the id I used in reviews. I try to follow some "documents" but there aren't any - and those I find are only for WordPress block 's.
In the source below (you find this at the moment on every gym, as it isn't working, hidden link) - does not show the id from the filter.
<div id="wpv-view-layout-1297-CATTR4b6554074659c1733ba7284560285eb7" class="js-wpv-view-layout js-wpv-layout-responsive js-wpv-view-layout-1297-CATTR4b6554074659c1733ba7284560285eb7" data-viewnumber="1297-CATTR4b6554074659c1733ba7284560285eb7" data-pagination="{"id":"1297","query":"normal","type":"disabled","effect":"fade","duration":500,"speed":5,"pause_on_hover":"disabled","stop_rollover":"false","cache_pages":"enabled","preload_images":"enabled","preload_pages":"enabled","preload_reach":1,"spinner":"builtin","spinner_image":"","callback_next":"","manage_history":"enabled","has_controls_in_form":"disabled","infinite_tolerance":0,"max_pages":0,"page":1,"base_permalink":"/muay-thai-gym/nicha-muay-thai-gym/?wpv_view_count=1297-CATTR4b6554074659c1733ba7284560285eb7&wpv_paged=WPV_PAGE_NUM","loop":{"type":"","name":"","data":[],"id":0}}" data-permalink="/muay-thai-gym/nicha-muay-thai-gym/?wpv_view_count=1297-CATTR4b6554074659c1733ba7284560285eb7"><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">First review</h4><div class="w-post-elm post_content usg_post_content_1"><p>next review</p><div class="w-html usg_html_3">3</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Third Review</h4><div class="w-post-elm post_content usg_post_content_1"><p>test</p><div class="w-html usg_html_3">4</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Shane test 2</h4><div class="w-post-elm post_content usg_post_content_1"><p>te</p><div class="w-html usg_html_3">4</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Shane review</h4><div class="w-post-elm post_content usg_post_content_1"><p>test</p><div class="w-html usg_html_3">5</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">My own summary</h4><div class="w-post-elm post_content usg_post_content_1"><p>Just something about this gym</p><div class="w-html usg_html_3">4</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Simon Vetterli</h4><div class="w-post-elm post_content usg_post_content_1"><p>Simon Vetterli, Simon Vetterli</p><div class="w-html usg_html_3">3</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Simon Vetterli, test 888</h4><div class="w-post-elm post_content usg_post_content_1"><p>test 888, test 888, test 888, test 888</p><div class="w-html usg_html_3">5</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Simon Vetterli, test</h4><div class="w-post-elm post_content usg_post_content_1"><p>Test 33333</p><div class="w-html usg_html_3">5</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Great experience in the Gym from a Swiss owner</h4><div class="w-post-elm post_content usg_post_content_1"><p>Great experience in the Gym from a Swiss owner, Great experience in the Gym from a Swiss owner</p><div class="w-html usg_html_3">5</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Great Muay Thai Gym</h4><div class="w-post-elm post_content usg_post_content_1"><p>I was here for some weeks in January 2020</p><div class="w-html usg_html_3">4</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article><article class="w-grid-item post-1301 review type-review status-publish hentry" data-id="1301"><div class="w-grid-item-h"><div class="w-vwrapper usg_vwrapper_2 align_left valign_top grid_arrow_bottom"><h4 class="w-post-elm post_title usg_post_title_1 align_left entry-title color_link_inherit">Great Muay Thai Gym on Koh Samui</h4><div class="w-post-elm post_content usg_post_content_1"><p>I was in 2019 for 3 weeks on Samui and did some …</p><div class="w-html usg_html_3">5</div></div></div><div class="w-hwrapper usg_hwrapper_1 align_left valign_middle"><div class="w-vwrapper usg_vwrapper_1 align_left valign_top"><div class="w-hwrapper usg_hwrapper_2 align_left valign_top"><div class="w-html usg_html_1">Simon</div><div class="w-html usg_html_2">Vetterli</div></div></div></div></div></article></div>
Hi Simon,
After going through and doing a bit of debugging and investigation of the gravity forms API. I find that only the hook below works.
add_action( 'gform_after_submission_2', 'apc_toolset_setparent', 10, 2 ); function apc_toolset_setparent($entry, $form ) { $created_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' ); toolset_connect_posts( 'muay-thai-gym-review', $entry[9], $created_posts[0]['post_id'] ); }
Given that i'm not familiar with the gravity forms API I cannot say exactly why the hook below isn't working
add_filter( 'gform_advancedpostcreation_post_after_creation_2', 'apc_toolsset_setparent', 10, 4 ); function apc_toolset_setparent( $post_id, $feed, $entry, $form ) { toolset_connect_posts( 'muay-thai-gym-review', $entry[8], $post_id ); }
Even though you have the advance post creation module installed and active. You can go ahead and test it on your end and check if it works.
I've already performed a test on your end and setup the view filters to use the post relationship instead of the id in the fields so this should work now with listing the correct information. As it stands you don't need to make any changes to the site.
Thanks,
Shane
Dear Shane
Indeed - yes, this is working! thanks
The next step would be - that I have the review as a slider...
I am not sure how I do it in the view correctly. Otherwise I try to add some html/css stuff around the output in the view.
How do I set correct the view, that I get a slider?
Regards,
Simon
My issue is resolved now. Thank you!
The result You find here: hidden link - with the slider I have now.
Thank You