1

I would like to be able to hide a widget in the front-end if the user is logged in and only display the widget when the user is not logged in.

I have found a plugin that does this called Widget Logic however i don't want to install too many plugins especially for something as small as this.

Your help will be much appreciated.

2

If you're comfortable changing the code where the widget is outputted you could use the is_user_logged_in() function. Something like this:

<div id="widget_area">
    <?php
        if ( is_user_logged_in() ) {
            // show nothing
        } else {
            dynamic_sidebar('widget_name');
        }
    ?>
</div>

The downside being that this is now hard coded and you might have to add this function in a few different files.

Steve

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.