-1

How can I make a div box with "id=private" that is inside a post only visible to the author of the post?

I made it for the admin, but I want the id to be visible only to the author of the post.

Example:

If the author is logged in, he should see the content with id=private.

but

if another user is logged in, he should not see the content with the id=private.

My solution for admin:

/* hide role-specific div */
#privat {
  display: none;
}

body.logged-in.admin-bar #privat {
  /* Admin is logged in*/
  display: flex;
}
  • You need a server-side solution to detect the author, and remove the box from the page altogether, if the requester is not the author. It's easy to override CSS with the DevTools. – Teemu May 27 '21 at 08:56
  • 3
    You have asked the same question about an hour ago. Just be patient and wait for an answer instead of asking the same question multiple times. – Geshode May 27 '21 at 08:57
  • Does this answer your question? [How can I display a div box with ID only for the corresponding author of the wordpress page?](https://stackoverflow.com/questions/67717262/how-can-i-display-a-div-box-with-id-only-for-the-corresponding-author-of-the-wor) – Geshode May 27 '21 at 08:57

1 Answers1

0

This might help you- [With PHP MySQL]

if (isset($_SESSION['loggedin'])) {

     <div id="private">Your content</div>

}

No need for the CSS code For using this you will have to make login form with PHP MySql

Dharman
  • 30,962
  • 25
  • 85
  • 135