msrougi

Bloquear acesso para não assinantes/não admins

Apr 6th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2. if ( have_posts() ) : while ( have_posts() ) : the_post();
  3.     $private = get_post_custom_values("private");
  4.     if (isset($private[0]) && $private == "true") {
  5.  
  6.         if ( current_user_can( 'administrator' ) ) {
  7.         the_title();
  8.         the_content();
  9.         } else if ( current_user_can( 'subscriber' ) )  {
  10.                 the_title();
  11.                 the_content();
  12.                } else  {            // text to show instead the post
  13.                     echo 'this post is private';
  14.         }
  15.  
  16.  
  17.     } else {        // this is visible to all
  18.         the_title();
  19.         the_content();
  20.     }
  21.  
  22. endwhile;
  23. endif;
  24. ?>
Add Comment
Please, Sign In to add comment