Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #21225

    I need to make some text visible in a text widget ONLY to logged in users. I’m using this conditional code directly in a sidebar text widget, but it does not work. It does not hide the text for anonymous users.Can you help please?

    `<?php if (is_user_logged_in() ) { //only logged in user can see this ?>

    <div><p>Text only for logged in users</p></div>

    <?php } ?> `


    Hi HouseofStrauss,

    In order to use php in widgets, you need to use a plugin like: http://wordpress.org/extend/plugins/php-code-widget/

    There is an example of is_user_logged_in on the codex which should help:

    if ( is_user_logged_in() ) {
    echo 'Welcome, registered user!';
    } else {
    echo 'Welcome, visitor!';




    Ok, thanks Devin, just wondered if the theme had removed the code filters by default. Obviously not. Thanks…


    Hey HouseofStrauss,

    No I don’t believe so but I wasn’t sure if you might have been trying it in a regular text widget or may not have had the example as a reference for correct syntax :)



Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Text widget visible only for logged in users’ is closed to new replies.