JoshLewis Posted May 15, 2020 at 10:32 PM Share Posted May 15, 2020 at 10:32 PM (edited) Trying to create a filter for reviews to inherit the listing's relations so that if people view listings state/country/city/area, they could show the latest reviews in those listings. function inherit_listing_parents($data, $wpdb) { global $wpdb; $listing_id; $listing_id = $data['Review']['pid']; $table_name = $wpdb->prefix."jreviews_content"; if(!empty($listing_id) { $results = $wpdb->get_row($wpdb->prepare("SELECT `jr_parents` FROM `".$table_name."` WHERE `contentid` = $listing_id", $listing_id)); } /* Before assigning $results->jr_parents we should use a static value for confirming our ability to save review relations */ $data['Field']['Review']['jr_ascentparents'][0] = "21"; $data['__raw']['Field']['Review']['jr_ascentparents'][0] = "21"; return $data; } Clickfwd\Hook\Filter::add('review_save_pre', 'inherit_listing_parents', 10); There may be a security check on JReviews preventing $data['Field']['Review']['jr_ascentparents'][0] from saving. When using dd() function it shows "21" in the response with no extra spaces in the preferred syntax. Have also tried other variations such as "*21*". Can save values to a text field with no problems, but saving to relations is a bit trickier. Edited May 15, 2020 at 10:33 PM by JoshLewis Link to comment
Alejandro Posted May 15, 2020 at 11:13 PM Share Posted May 15, 2020 at 11:13 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
JoshLewis Posted May 16, 2020 at 12:08 AM Author Share Posted May 16, 2020 at 12:08 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted May 16, 2020 at 12:19 AM Share Posted May 16, 2020 at 12:19 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Jnnis Posted May 16, 2020 at 06:20 AM Share Posted May 16, 2020 at 06:20 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
JoshLewis Posted May 16, 2020 at 06:35 AM Author Share Posted May 16, 2020 at 06:35 AM (edited) This section is only visible with a valid subscription. If you have a valid subscription, please login. Edited May 16, 2020 at 06:36 AM by JoshLewis Link to comment
Alejandro Posted May 16, 2020 at 12:44 PM Share Posted May 16, 2020 at 12:44 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. JoshLewis 1 Link to comment
JoshLewis Posted May 16, 2020 at 06:04 PM Author Share Posted May 16, 2020 at 06:04 PM (edited) This section is only visible with a valid subscription. If you have a valid subscription, please login. Edited May 16, 2020 at 06:10 PM by JoshLewis Link to comment
JoshLewis Posted May 16, 2020 at 06:16 PM Author Share Posted May 16, 2020 at 06:16 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted May 16, 2020 at 06:22 PM Share Posted May 16, 2020 at 06:22 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. JoshLewis 1 Link to comment
Recommended Posts