Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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 and blankspaces 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 and blankspaces Jul 2 '13 at 15:29
or is a valid logical operator –  s_ha_dum Jul 2 '13 at 15:39
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.