WordPress.org

Support

Support » Plugins and Hacks » Show page element (gallery, in this case) only if user not logged in

Show page element (gallery, in this case) only if user not logged in

  • This is something I’d like to be able to do in general, however, here is an example using the Featured Content Gallery.

    I placed this line of code in the right spot of my template’s index.php file:
    <?php include (ABSPATH . ‘/wp-content/plugins/featured-content-gallery/gallery.php’); ?>
    (shows the gallery)

    I know the WP funtion/logic to use:
    !is_user_logged_in()

    But, I don’t know how to combine them to say:

    If the user is not logged in, then show the gallery.

    I could try to do something like this:

    <?php
    $RandomNumber = rand(1, 2);

    if ($RandomNumber == ‘1’) {
    echo ‘The number was 1’;
    } Else {
    echo ‘The number was 2’;
    }
    ?>

    and try to say if user not logged in, then string, if not, then do nothing…or, can I somehow only tell the include statement to include, if the user is not logged in.

    Assistance would be warmly appreciated, and I am willing to plow through some tutorials too…as long as they take me to the right goal 🙂

    Cheers!
    Dainis

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show page element (gallery, in this case) only if user not logged in’ is closed to new replies.