• James posted an update 1 year, 2 months ago

    Want to show a welcome message to logged out users only?
    There are a few ways you can do this but the easier ways are:

    Embedding this code into your theme in the place you want the message to display and using this code:

    <?php

    if ( is_user_logged_in() ) {

    echo ”;

    } else {

    echo ‘Welcome, visitor! Why Not sign up!’;

    }

    ?>

    *Note: The code will be overwritten the next time you update your theme so it is advised to create a child theme and insert your welcome message there instead.

    OR an even easier option would be to use widgets.
    Here is a very simple trick in WordPress to show certain widgets to users that are not logged into your site (perfect for Welcome to our site widgets and the like). Simply download the popular plugin widget logic and then place the widget where you want your message to be and then in the widget logic section now added to your widget you can either add:

    is_user_logged_in() —to display the widget for logged in users only!

    !is_user_logged_in() — to display the widget for logged out users only!

    Hope this helps!