1

I'd like to display a message when current user's post is set to private. The code below does this, however only works when you are on the actual post page. I'd like for my message to be displayed site wide for the user.

<?php

// if post is private and needs to be approved by an admin
if(is_single() && get_post_status() == "private" && get_post_meta(get_the_ID(), "notactive", true) == "1" && (get_the_author_meta('ID') == $userid || current_user_can('level_10'))) {
if(current_user_can('level_10')) {  ?>
7
  • What do you mean exactly? What are you trying to achieve? Commented Jan 14, 2019 at 22:56
  • It's not clear what you are trying to do, e.g. what do you mean when you say "return this"? Please edit your question and rephrase the wording so that it's clearer, I think you're assuming we know things about your setup and what you're trying to do that we don't
    – Tom J Nowell
    Commented Jan 14, 2019 at 23:08
  • I'm sorry, it seems anytime I type on here it seems like I can't speak English. I tried revising it. Let me know if it still doesn't work.
    – Joe Landry
    Commented Jan 14, 2019 at 23:18
  • 1
    @JoeLandry so if I understand this correctly, you want a site-wide banner message that x posts are set to private of/for the current user? X being the number of posts the user has set to private, of which it only shows to the current user.
    – Howdy_McGee
    Commented Jan 14, 2019 at 23:21
  • I am not worried about the message itself, I just would like whatever message I do set, to be displayed site wide. You can see the code grabs the current post instead of grabbing user posts.
    – Joe Landry
    Commented Jan 14, 2019 at 23:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.