CSTLdesign News

How to Show WordPress Widgets Only to Logged In Users

Ever need to show a WordPress widget only to logged in users? Or maybe you have the opposite need: you want to show a widget only to users who are NOT logged in.

In this post, we’ll go over how to do both.


Using Widget Logic

Widget Logic is a very popular plugin that will help us accomplish our goal. While Widget Logic can help you do much more than hide or show a widget to logged in/logged out users, we’re going to focus this post on that particular task.

Once installed and activated, you will see an empty box at the bottom of each widget. (Appearance > Widgets)


In order to show a widget only to certain users, you will need to put some code in the box.

Of course there are two basic choices you have here:

1. Show widget only to users who ARE logged in:


2. Show widget only to users who are NOT logged in

Same code as above, but put an exclamation point (!) before it:


Here’s a look with the first bit of code in the box.


And here we can see this menu appearing only for logged in users.


As mentioned, Widget Logic will allow you to create lots of other conditional statements besides this one. You can see the plugin page (or search the web) for other pieces of code to insert.

Photo credit: gfpeck