Title: Comments from UI
Last modified: June 29, 2020

---

# Comments from UI

 *  Resolved [digitali17](https://wordpress.org/support/users/digitali17/)
 * (@digitali17)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/)
 * Hi
 * I’m trying to modify the plugin so you can add comments to a review direct from
   the page (instead of the admin panel).
 * I have added a comment section in the file templates/review.php. Now I need to
   get the review ID so I can link a comment to the review, when the user submit.
 * How can I get the ID?
    -  This topic was modified 5 years, 10 months ago by [digitali17](https://wordpress.org/support/users/digitali17/).
    -  This topic was modified 5 years, 10 months ago by [digitali17](https://wordpress.org/support/users/digitali17/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * (@geminilabs)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13051210)
 * Are you talking about WordPress comments, or the review response that you can
   add to a review when editing it in the admin?
 * You can get the Post ID of the review in the template like this:
 *     ```
       $postId = $review->ID;
   
       // OR with an extra check to make sure the $review object exists
   
       $postId = isset($review)
           ? $review->ID
           : 0;
   
       // OR using the glsr_get() helper function (using the safe apply_filters method)
       // Arguments are explained like this:
       //   1. function name
       //   2. arg1 = value to use if the plugin is not installed
       //   3. arg2 = object/array to search
       //   4. arg3 = object/array key to get the value from
       //   5. arg4 = value to return if the object/array key does not exist
   
       $postId = apply_filters('glsr_get', 0, $review, 'ID', 0);
       ```
   
 *  Thread Starter [digitali17](https://wordpress.org/support/users/digitali17/)
 * (@digitali17)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13060865)
 * Thank you very much 🙂
 * I have one more question…
    I made this code. When an admin is logged in, there
   will be an input box to response to a review. How can I save the response into
   the database, when the form is submitted?
 *     ```
       	<?php
       	$current_user = wp_get_current_user();
       	if (user_can( $current_user, 'administrator' )) { ?>
   
       	<form autocomplete="off" action="/post-comment.php" method="post"> 
       		<div> 
       			<input type="hidden" id="reviewid" name="reviewid" value=<?= $postId = $review->ID; ?> readonly> 
       			<input type="text" id="comment" name="comment" placeholder="Indtast dit svar til overstående review"> 
       		</div> 
       		<input type="submit" value="Indsend"> 
       	</form> 
       	<?php } ?>
       ```
   
    -  This reply was modified 5 years, 10 months ago by [digitali17](https://wordpress.org/support/users/digitali17/).
 *  Plugin Author [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * (@geminilabs)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13061423)
 * The response is saved as post meta of the review (using the `_response` meta_key).
 * For example, this is what Site Reviews does:
 *     ```
       $allowedHtml = [
           'a' => [
               'href' => [],
               'title' => [],
           ],
           'em' => [],
           'strong' => [],
       ];
       $response = trim(wp_kses($responseText, $allowedHtml));
       update_post_meta($postId, '_response', $response);
       ```
   
 *  Thread Starter [digitali17](https://wordpress.org/support/users/digitali17/)
 * (@digitali17)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13073441)
 * How can I implement that in my example?
 *  Plugin Author [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * (@geminilabs)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13078900)
 * Use that in whichever function you use to handle your form submission. Since 
   you are submitting your form to `/post-comment.php`, that’s probably where you
   would use it.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Comments from UI’ is closed to new replies.

 * ![](https://ps.w.org/site-reviews/assets/icon-256x256.gif?rev=3307009)
 * [Site Reviews](https://wordpress.org/plugins/site-reviews/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/site-reviews/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/site-reviews/)
 * [Active Topics](https://wordpress.org/support/plugin/site-reviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/site-reviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/site-reviews/reviews/)

## Tags

 * [comment](https://wordpress.org/support/topic-tag/comment/)
 * [response](https://wordpress.org/support/topic-tag/response/)

 * 5 replies
 * 2 participants
 * Last reply from: [Gemini Labs](https://wordpress.org/support/users/geminilabs/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/comments-281/#post-13078900)
 * Status: resolved