0

I am using the following loop to show the-content for only contributors as well as Google visitors. But somehow it is not working.

    <?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php if (current_user_can(‘contributor’) || strpos($_SERVER[HTTP_REFERER], "google") == true) { ?>
<?php the_content('');?><?php } ?>
<?php endwhile; ?>
<?php comments_template(); ?>
<?php else : ?>
<?php endif; ?>

Please help me on this.

1

From Codex :

Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly (see #22624) Instead, you may wish to try the check user role function put together by AppThemes.

I would propose to use is_user_logged_in() to check your function.

  • If this answer your question, please check it as answered please. – Simon Nov 27 '13 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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