computer code

The code below shows all that it takes to show or hide content when a user is either logged into your site or not.

<?php if (is_user_logged_in()){ ?>
<p>you are logged in</p>
<?php } else { ?>
<p>log-in please</p>
<?php }; ?>
When a user is logged in, they will see the “you are logged in” text. If they are not logged in, they will see the “log-in please” text.
This link might go into a little more detail about it. https://developer.wordpress.org/reference/functions/is_user_logged_in/