Title: Trying to tweak comments.php
Last modified: August 19, 2016

---

# Trying to tweak comments.php

 *  Resolved [snoogly](https://wordpress.org/support/users/snoogly/)
 * (@snoogly)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/)
 * I am building an educational web site. One element of the site is that all users
   must write comments on certain pages. However, I only want these comments to 
   be actually visible to admin (me), and one other user (this user would be different
   on every page).
 * I am trying to tweak **comments.php** so that the comments area is only shown
   to specified users (using user_ID).
 * This is the ‘if’ statement I am using (on this page, I need user ID #2 to be 
   able to see the comments):
 * `<?php if($user_ID == 2 || $user_ID == 1): ?>`
    COMMENTS ARE HERE `<?php endif;//
   end if $user_ID ?>`
 * That works, but the problem is that on other pages I need a different user_ID
   in the ‘if’ statement.
 * Of course I can’t create a different comments.php for every page! ~ so my question
   is:
 * **How can I easily change the user_ID value in the ‘if’ statement, depending 
   on the page?**

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

 *  [patricioqb](https://wordpress.org/support/users/patricioqb/)
 * (@patricioqb)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664566)
 * You can try something like…
 * <? if(($user_id = 1 and $post_id=8) or ($user_id = 2 and $_post_10)) { ?>
 * The problem is that you will have to update the file in every new post…
 *  Thread Starter [snoogly](https://wordpress.org/support/users/snoogly/)
 * (@snoogly)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664621)
 * Yes, the problem is the large number of pages involved ~ 50. Easy to tweak comments.
   php for one 1 page/1 user, but not for 50 pages and 10 users!
 *  Thread Starter [snoogly](https://wordpress.org/support/users/snoogly/)
 * (@snoogly)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664692)
 * Thanks to patricioqb I think I will be able to do what I want by matching userid’s
   to postid’s.
 * Something like this would do it – but how should I correctly list the 5 pages?
   Commas don’t work, and neither does ‘or’.
 * `<?php if($user_ID == 1 || $user_ID == 2 && $post->ID == 5,7,10 ,11,12: ?>`
 * Can a WP/PHP guru tell me how to correctly list those 5 pages?
 * Thanx
 *  [patricioqb](https://wordpress.org/support/users/patricioqb/)
 * (@patricioqb)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664707)
 * I am not WP guru, but I think I am PHP Guru 😛
 * What do you want? User 1 and 2 to see 5,7,10,11 and 12 post?
 * It should be:
 * >  <?php
   >  if(($user_ID == 1 OR $user_ID == 2) AND ($post->ID == 5 or $post->ID
   > == 7 or $post->ID == 10 or $post->ID == 11 or $post->ID == 12))
 *  Thread Starter [snoogly](https://wordpress.org/support/users/snoogly/)
 * (@snoogly)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664730)
 * Sweet. Yes indeed I want those users to see comments on those specific posts,
   I just didn’t know how to list them properly. But thanks to you, I do now!
 * This is great, as at last I can pull my course on presentation skills out of 
   Moodle and into WP.
 * The reason I need to tweak the comments.php, is that I upload videos of students’
   speeches – and other students write comments about them. The trick is that I 
   need them to write their comments ‘blind’, without reading comments written by
   other students. The only people who can read the comments are me (the teacher),
   and the student who’s speech is being commented on.
 * Thanks again patricioqb
 *  [patricioqb](https://wordpress.org/support/users/patricioqb/)
 * (@patricioqb)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664733)
 * Perfect then!
 * You are welcome! 🙂

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

The topic ‘Trying to tweak comments.php’ is closed to new replies.

## Tags

 * [$user_ID](https://wordpress.org/support/topic-tag/user_id/)
 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [comments.php](https://wordpress.org/support/topic-tag/comments-php/)
 * [edit](https://wordpress.org/support/topic-tag/edit/)
 * [hidden](https://wordpress.org/support/topic-tag/hidden/)
 * [hide](https://wordpress.org/support/topic-tag/hide/)
 * [if](https://wordpress.org/support/topic-tag/if/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [patricioqb](https://wordpress.org/support/users/patricioqb/)
 * Last activity: [18 years, 6 months ago](https://wordpress.org/support/topic/trying-to-tweak-commentsphp/#post-664733)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
