Own IDs instead of post_id
-
I have a set of chatbots that are generated from database automatically. Each chatbot has got an ID like “chatbot-7igwy3”. Is it possible to use this ID somehow instead of PostID? I am asking because I do only have one page for all chatbots. The URL looks like /chat?id=chatbot-7igwy3
Any Ideas on that? Thanks a lot in advance!
-
Are you trying to assign reviews to your chatbots?
The assigned_posts option only works with posts that have a Post ID and permalink. If you need to assign reviews to something more intangible then you will need to use the assigned_terms option instead to assign the review to categories. This means that you would first need to create the categories before they can be assigned to reviews.
If you want to automatically generate categories based on the chatbot name in the URL query, then you will be able to do this after the next plugin update with the following code snippet: https://pastebin.com/7uQKgVR6
HOWEVER, do this with caution! I don’t recommend it simply because it opens up your website to abuse. Unless you modify the code to restrict the chatbot names that are allowed then anyone could add random chatbot names to the URL in order to spam you with tons of new categories.
Wow that’s a really fast reply and solution. Thanks a lot!
Forgot to mention, with that snippet enabled you would then use
chatbot_id
as theassigned_terms
value like this:[site_reviews_form assigned_terms="chatbot_id"]
Or this:
Yes – got that. When do you think you will push the update? Best regards!
Possibly tomorrow.
Hi! Any news regarding the update? I am keen to try your plugin for my use case…
It’s been delayed to later this week.
Thanks for the prompt information!
Hey, I see there’s Version 7.0.17 out there since yesterday. Will the snipped mentioned above work with this version? Best regards!
Yes it should.
Hi! Thank you very much for pushing the update and the support so far. We started implementing the feature but still have the problem that the ratings and reviews don’t stick to chatbot_id in the assigned_terms. The programmer asked me to send this code:
public function site_reviews_terms($ttid, $term, $taxonomy) { if (!get_option('aietrs_reviews_enabled', 0) || !empty($ttid) || substr($term, 0, 10) !== 'chatbot_id') { return $ttid; } ie_log('AI Engine Translations',array('site_reviews_terms starting term:',$term)); $url = filter_input(INPUT_SERVER, 'REQUEST_URI'); $path = wp_parse_url($url, PHP_URL_PATH); $query = wp_parse_args(wp_parse_url($url, PHP_URL_QUERY)); $botId = strlen($term) > 10 ? explode('chatbot_id_',$term)[1] : $query['id']; if (!$botId) { ie_log('AI Engine Translations',array('[ERROR] site_reviews_terms no botId',$term,$path)); return $ttid; } ie_log('AI Engine Translations',array('site_reviews_terms botId:',$botId,$term)); $chatbot = $this->get_chatbot($botId); if (!$chatbot || !isset($chatbot['translations']) || empty($chatbot['translations'])) { ie_log('AI Engine Translations',array('site_reviews_terms no translation:',$botId,$term)); return $ttid; } $term = wp_create_term($botId, $taxonomy); if (is_wp_error($term)) { ie_log('AI Engine Translations',array('site_reviews_terms wp error:',$botId,$term)); return $ttid; } ie_log('AI Engine Translations',array('site_reviews_terms return term:',$term,$botId,$term['term_taxonomy_id'])); return $term['term_taxonomy_id'] ?? 0; } add_filter('site-reviews/assigned_terms/term_id', array($this, 'site_reviews_terms'), 10, 3);
It it’s helpful I can also send the link so that you can see the implementation…
Oops, I used the wrong user account. The message was from me.
It it’s helpful I can also send the link so that you can see the implementation…
What is the URL?
https://staging2.xpandai.one/assist/
thanks! ??????
… the dev asked me to tell you that it works on dev site but not mine.
here are some logs:
[2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-ti175w” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_e3cf2173″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 175 [term_taxonomy_id] => 175 ) [2] => chatbot-ti175w [3] => 175 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-ti175w [2] => chatbot_id_chatbot-ti175w ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-ti175w ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-zwzvof” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_87d574a9″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 174 [term_taxonomy_id] => 174 ) [2] => chatbot-zwzvof [3] => 174 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-zwzvof [2] => chatbot_id_chatbot-zwzvof ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-zwzvof ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-ipp0iv” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_387c367d” data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 173 [term_taxonomy_id] => 173 ) [2] => chatbot-ipp0iv [3] => 173 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-ipp0iv [2] => chatbot_id_chatbot-ipp0iv ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-ipp0iv ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-lc0u5h” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_26b87797″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 172 [term_taxonomy_id] => 172 ) [2] => chatbot-lc0u5h [3] => 172 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-lc0u5h [2] => chatbot_id_chatbot-lc0u5h ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-lc0u5h ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-fuhqs9″ hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_d99ea930″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 171 [term_taxonomy_id] => 171 ) [2] => chatbot-fuhqs9 [3] => 171 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-fuhqs9 [2] => chatbot_id_chatbot-fuhqs9 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-fuhqs9 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-aew6kf” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_b7346876″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms return term: [1] => Array ( [term_id] => 170 [term_taxonomy_id] => 170 ) [2] => chatbot-aew6kf [3] => 170 ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms botId: [1] => chatbot-aew6kf [2] => chatbot_id_chatbot-aew6kf ) [2024-08-18 15:19:15] User: 2 Array ( [0] => site_reviews_terms starting term: [1] => chatbot_id_chatbot-aew6kf ) [2024-08-18 15:19:15] User: 2 Array ( [0] => shortcode: [1] => [site_reviews_summary assigned_terms=”chatbot_id_chatbot-2laozb” hide=”bars,if_empty,summary”] [2] => rating: [3] => <div class=”glsr glsr-default” id=”glsr_d0b73dc9″ data-from=”shortcode” data-shortcode=”site_reviews_summary” data-hide=”["bars","if_empty","summary"]”><div class=”glsr-summary-wrap”> <div class=”glsr-summary”> <div class=”glsr-summary-rating”><span class=”glsr-tag-value”>4,3</span></div> <div class=”glsr-summary-stars”><div class=”glsr-star-rating glsr-stars” role=”img” aria-label=”Rated 4,3 out of 5 stars based on 3 ratings” data-rating=”4.3″ data-reviews=”3″><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-full” aria-hidden=”true”></span><span class=”glsr-star glsr-star-half” aria-hidden=”true”></span></div></div> </div> </div></div> )
- You must be logged in to reply to this topic.