0

I have a CPT called Topics. And admin or editor can only make topics and It can be assigned to authors. I have a meta box where there will be a list of authors and Admin/Editor can choose whom to assign the Topic. So the assigned topic will be used by authors to write the post. But what I wanted was to show only the Topics only to the author that I have assigned. If a post is assigned to author1 I don't want author2 to see to use that. So, the author name will be in meta box and in the Topic CPT column. So, my condition would be if($get_current_user == get_post_meta( $post_id, 'cruiser_writer_value_key', true )){ } Topics CPT

So as you can see in the picture. There are three users and I just want Author2 to see the post assigned to him. How can I hide the post columns to authors if it has not been assigned to them. But admin should see all the post.

  • first of all use == instead of =, the later one always return true, and use && instead. if(($get_current_user == $writer_list_value) and ($writer_list_value == get_post_meta( $post_id, 'cruiser_writer_value_key', true ))) – Arash Rabiee Feb 6 at 11:11
  • Hey, I am really sorry for the Typo there. It was just during this question I hadn't made the mistake in my actual code. Anyway, I have updated that. But my main question was how to show it only to the author that I have on the Writer field. – Ayush O' Lee Feb 6 at 11:34

Your Answer

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

Browse other questions tagged or ask your own question.