WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. dainismichel
    Member
    Posted 5 years ago #

    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

  2. dainismichel
    Member
    Posted 5 years ago #

    <?php
    if(!is_user_logged_in())
    {
    include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php');
    }
    ?>

    from: the kind folks at:
    http://www.featuredcontentgallery.com/forum/only-visible-if-visitor-not-logged-in-709.html#p3006

Topic Closed

This topic has been closed to new replies.

About this Topic