Site icon O'Brien Media Website Design & Support

WordPress: Display a message or other text in a page or post only to logged in users

wordpress-display-a-message-or-other-text-in-a-page-or-post-only-to-logged-in-users.jpg

You can use this to post advice or reminders to logged in users when they need to perform different tasks.

All you have to do is add the following anywhere in your theme you want to display the message.

Create a shortcode to detect logged in users

To turn this into a shortcode so you can use it in your posts you can just use the below snippet add this into your functions.php page.

To use this shortcode in your post use the following code.

 

[user_only]User is logged in.[/user_only]

 

Exit mobile version