WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a template file that I am using as page, I want to allow only 2 users to post comments and allow to all other users to only see these comments( not allow them add comments).

my template file is:

<?php get_header();  ?>

if (get_current_user_id()==1 or get_current_user_id()==2 ) {

comments_template( '', true );
comments_template( '/comments-with-no-form.php', true );

} ?>

<?php get_footer(); ?>

Normally, when I remove comments_template from single.php, or just remove the <?php comment_form(); ?> from comments.php, changes apply. But in separate template file, nothing is working. The file comments-with-no-form.php is never executed (only style of comments.php changes).

Your help is appreciated.

share|improve this question
up vote 1 down vote accepted

This if statement is really wrong :

if (get_current_user_id()==1 or get_current_user_id()==2 

should be :

$user_id = get_current_user_id();
if ($user_id==1 || $user_id==2 )
share|improve this answer
waw. I was thinking the problem is in comments_template. what is wrong in my statement? is is the or. – whiteletters in blankpapers Jul 2 '13 at 15:23
Ahhhh, In my editor I saw its color changing, my god I thought my editor know only PHP. :-) thanks man – whiteletters in blankpapers Jul 2 '13 at 15:29
I was wrong this is not due to or but the way you called get_current_user_id() and use it. Sorry :/ – JMau Jul 2 '13 at 15:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.