Suporte » Temas » Permitir apenas que o usuário veja apenas os seus posts e o admin ver todos

Visualizando 3 respostas - 1 até 3 (de um total de 3)
  • Tente isto abaixo


    <?PHP if ( ! is_admin() ) {
    //mostre todos os posts
    }
    else {// mostre alguns }

    Se possivel é so adaptar para situações especificas

    Criador do tópico Cabral Sepia

    (@cabral-creativ3)

    código abaixo é para quando todos os usuários possam ver apenas os seus posts inclusive admin pode ver apenas o seu post.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php if ( !is_user_logged_in() )  { ?>
     <?php  }  elseif ( $user_ID == get_post($post_id)->post_author ) { ?>
     <?php the_title();?> 
    
    		 <?php the_content();?>    
    
                 	  <?php the_category();?>
            <?php the_author_posts_link(); ?>
    
          <?php } ?>
    
             <?php endwhile; else:?>
    
    		<?php endif;?>
    Criador do tópico Cabral Sepia

    (@cabral-creativ3)

    aaaaaaaaaaa consegui segue para quem quiser !!!

    Admin consegue ver todos os posts e os usuários conseguem ver apenas o seus posts!

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    // linha abaixo é o segredo  para o admin  ver todos
    
      <?php global $current_user; get_currentuserinfo(); if ($current_user->user_level == 10 ) { ?>
    
    <?php the_title();?>
    <?php the_content();?>
    
    <?php } else {   ?>
    
    // usuario vendo apenas os seus posts 
    
    <?php if ( !is_user_logged_in() )  { ?>
     <?php  }  elseif ( $user_ID == get_post($post_id)->post_author ) { ?>
    
          <?php the_title();?>
    <?php the_content();?>
    
          <?php } ?>
    
          <?php } ?>
    
             <?php endwhile; else:?>
    
    		<?php endif;?>
Visualizando 3 respostas - 1 até 3 (de um total de 3)
  • O tópico ‘Permitir apenas que o usuário veja apenas os seus posts e o admin ver todos’ está fechado para novas respostas.