I've got a gallery on a listing page that I want to only display to logged in users. I'm trying to use the function is_user_logged_in()
but I'm failing to work out exactly how to implement it.
I'm a beginner trying to work more in the PHP files rather than plugins/shortcodes.
This is the code, how would I add the is_user_logged_in()
so the gallery only displays to logged in users?:
<?php
//get the listing gallery
$photos = listable_get_listing_gallery_ids();
if ( ! empty( $photos ) ) : ?>
<div class="entry-featured-carousel">
<?php if ( count( $photos ) == 1 ):
$myphoto = $photos[0];
$image = wp_get_attachment_image_src( $myphoto, 'listable-featured-image' );
$src = $image[0]; ?>
<div class="entry-cover-image" style="background-image: url(<?php echo listable_get_inline_background_image( $src ); ?>);"></div>
<?php else: ?>
<div class="entry-featured-gallery">
<?php foreach ( $photos as $key => $photo_id ):
$src = wp_get_attachment_image_src( $photo_id, 'listable-carousel-image' ); ?>
<img class="entry-featured-image" src="<?php echo $src[0]; ?>" itemprop="image" />
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>