I’m trying to start myself off here but I can’t get my head around it…
How can I hide an author’s post content/meta from everyone except the post author and admin? This is my scenario…
Schools and teachers publish their own custom posts
Schools/Admin can see all teachers posts but only the teacher who published the post can see their post, other teachers can’t see other teacher’s posts.

1 Answer
1

You can try below code –

<?php
    global $current_user;


     if ((is_user_logged_in() && $current_user->ID == $post->post_author) || current_user_can( 'manage_options' ))  {
        echo 'my post';
    }
?>

Check below link also-

https://codex.wordpress.org/Function_Reference/current_user_can

Leave a Reply

Your email address will not be published. Required fields are marked *