Support » Fixing WordPress » Password Protect Pages With Custom Fields

  • Resolved FelixDaHousecat

    (@felixdahousecat)


    Can anyone tell what code and exactly where I should place it on a page with a custom field so that everything is hidden?

Viewing 7 replies - 1 through 7 (of 7 total)
  • graphical_force

    (@graphical_force)

    We need much more information in order to help you. Can you please describe exactly what you are trying to do or how might you see the code working?

    FelixDaHousecat

    (@felixdahousecat)

    Hi, thank you for your reply. I have made a page for my template that inserts an Adobe Lightroom gallery. It works perfectly. However, I want that gallery/page to be password protected. When I publish the page as password protected the gallery still shows. I believe that I need to add some extra code to make the custom field protected too. This is the part that I can’t seem to do. Here is what I have done so far:

    get_header(); ?>
    
    <?php $gallery_link = get_post_meta( get_the_ID(), 'gallery_link', true ); ?>
    
    		<div id="primary" class="content-area span12">
    			<div id="content" class="site-content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    				<h1><?php the_title(); ?></h1>	
    
    				<?php the_content(); ?>
    
                    <iframe src="<?php echo $gallery_link; ?>" width="100%" height="1100"></iframe>	
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content .site-content -->
    		</div><!-- #primary .content-area -->
    
    <?php get_footer(); ?>
    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    FelixDaHousecat

    (@felixdahousecat)

    Hi, thanks, I have tried this but I don’t understand where to insert the code and if I use the example in its exact form. Can you tell where I insert the code shown?

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try this:

    <?php get_header(); ?>
    
    <?php $gallery_link = get_post_meta( get_the_ID(), 'gallery_link', true ); ?>
    
    		<div id="primary" class="content-area span12">
    			<div id="content" class="site-content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    				<h1><?php the_title(); ?></h1>
    
    				<?php the_content(); ?>
    				<?php if ( ! post_password_required() && !empty( $gallery_link ) ) : ?>
    				<iframe src="<?php echo $gallery_link; ?>" width="100%" height="1100"></iframe>
    				<?php endif; ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content .site-content -->
    		</div><!-- #primary .content-area -->
    
    <?php get_footer(); ?>

    FelixDaHousecat

    (@felixdahousecat)

    Oh my god! Thank you so much – It works! I spent hours yesterday trying to fix this. Thank you so much for your help :o)

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    You’re welcome 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Password Protect Pages With Custom Fields’ is closed to new replies.