I want to completely hide the element if the user did not log in to my site on WordPress.
There is an identified class called .logged-in
on WordPress, which is only for logged-in users. I can hide it by CSS, which is something like :not(.logged-in) .element{display: none;}
, but this is unsafe because people still can inspect the element and set it to visible or view the page source.
Is there a way to really hide the element or remove it completely by a class name ( because I need to hide several elements with the same class name ) if the user did not log in by PHP?
.container {
height: 100vh;
width: 100%;
background-color: #ddd;
display: flex;
align-items: center;
justify-content: center;
}
.element {
font-size: 60px;
background-color: blue;
color: white;
padding: 15px 30px;
}
<div class="container">
<p class="element">Hide me please</p>
</div>