I have code

global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( ! user_can( $current_user, "subscriber" ) ) // Check user object has not got subscriber role
    echo '<span>if user, can view post content</span>';
    echo '<span>if no user, can not view</span>';


How to make

echo '<span>if user, can view post content</span>';

=> i try it, but no active :(

echo '<span><div class="col-sm-12">
<h2><?php the_title(); ?></h2>  


<a class="btn btn-success">Tồng số chữ : <?php if(function_exists('bac_post_word_count')) { bac_post_word_count(); }?></a>
  <a target="_blank" rel="noopener noreferrer" href="<?php 
  $meta = get_post_meta( get_the_ID(), 'download' );
  if( !empty($meta) ) {
    echo $meta[0];
?>" class="btn btn-warning"><span class="glyphicon glyphicon-cloud-download"></span> Tải về .docx</a></p>

<?php the_content(); ?>


Read more here: How to make id user can be view content


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: