• Resolved flameash

    (@flameash)


    hi everyone

    I created a page template called subscriber only, so pages under this template can be only viewed by subscribers.

    so I didnt do much coding except adding the following code to a normal page.php
    <?php if(is_user_logged_in()): ?>
    <?php else:
    wp_die(‘Sorry, you must first log in to request a sample. You can register free here.’);
    endif; ?>

    the template is working fine. logins are working fine.
    but the global css messed up on pages under this template.

    I can’t figure out what went wrong.
    please help

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you give us a link? Or post the code from that template?

    Thread Starter flameash

    (@flameash)

    thx for responding.

    the following code is page-requirelogin.php file

    <?php
    /**
     * @package WordPress
     * @subpackage Motion
     */
    /*Template Name: Subscribers Only */
    ?>
    
    <div id="main">
    	<div id="content" class="full">
    
                    <?php if(is_user_logged_in()): ?>
                    <?php else:
    wp_die('Sorry, you must first <a href="/blogs/wp-login.php">log in</a> to request a sample. You can <a href="/blogs/wp-login.php?action=register">register free here</a>.');
    endif; ?>
    
                    <?php get_header(); ?>
    		<?php if ( have_posts() ) : ?>
    
    		<?php while ( have_posts() ) : the_post(); ?>
    
    		<?php if ( function_exists( 'wp_list_comments' ) ) : ?>
    		<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    		<?php else : ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<?php endif; ?>
    
    			<div class="posttop">
    				<h2 class="posttitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    			</div>
    
    			<div class="postcontent">
    				<?php the_content( 'Read more ?' ); ?>
    				<div class="linkpages"><?php wp_link_pages( 'link_before=<span>&link_after=</span>' ); ?></div>
    			</div>
    			<small><?php edit_post_link( 'Admin: Edit this entry' , '' , '' ); ?></small>
    		</div><!-- /post -->
    
    		<div id="comments">
    		<?php if ( function_exists( 'wp_list_comments' ) ) : ?>
    		<!-- WP 2.7 and above -->
    		<?php comments_template( '', true ); ?>
    		<?php else : ?>
    		<!-- WP 2.6 and below -->
    		<?php comments_template(); ?>
    		<?php endif; ?>
    		</div><!-- /comments -->
    
    		<?php endwhile; ?>
    
    		<?php else : ?>
    
    		<div class="post">
    			<div class="posttop">
    				<h2 class="posttitle"><a href="#">Oops!</a></h2>
    			</div>
    			<div class="postcontent">
    				<p>What you are looking for doesn't seem to be on this page...</p>
    			</div>
    		</div><!-- /post -->
    		<?php endif; ?>
    
    	</div><!-- /content -->
    
    </div><!-- /main -->
    
    <?php get_footer(); ?>

    This is a new php file i added into my motion theme as the Subscriber Only template.

    <?php
    /**
     * @package WordPress
     * @subpackage Motion
     */
    /*Template Name: Subscribers Only */
    ?>
    
    <div id="main">
    	<div id="content" class="full">
     <?php get_header(); ?>
                    <?php if(is_user_logged_in()): ?>
    
    		<?php if ( have_posts() ) : ?>
    
    		<?php while ( have_posts() ) : the_post(); ?>
    
    		<?php if ( function_exists( 'wp_list_comments' ) ) : ?>
    		<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    		<?php else : ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<?php endif; ?>
    
    			<div class="posttop">
    				<h2 class="posttitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    			</div>
    
    			<div class="postcontent">
    				<?php the_content( 'Read more ?' ); ?>
    				<div class="linkpages"><?php wp_link_pages( 'link_before=<span>&link_after=</span>' ); ?></div>
    			</div>
    			<small><?php edit_post_link( 'Admin: Edit this entry' , '' , '' ); ?></small>
    		</div><!-- /post -->
    
    		<div id="comments">
    		<?php if ( function_exists( 'wp_list_comments' ) ) : ?>
    		<!-- WP 2.7 and above -->
    		<?php comments_template( '', true ); ?>
    		<?php else : ?>
    		<!-- WP 2.6 and below -->
    		<?php comments_template(); ?>
    		<?php endif; ?>
    		</div><!-- /comments -->
    
    		<?php endwhile; ?>
    
    		<?php else : ?>
    
    		<div class="post">
    			<div class="posttop">
    				<h2 class="posttitle"><a href="#">Oops!</a></h2>
    			</div>
    			<div class="postcontent">
    				<p>What you are looking for doesn't seem to be on this page...</p>
    			</div>
    		</div><!-- /post -->
    		<?php endif; ?>
               <?php else:
    wp_die('Sorry, you must first <a href="/blogs/wp-login.php">log in</a> to request a sample. You can <a href="/blogs/wp-login.php?action=register">register free here</a>.');
    endif; ?>
    	</div><!-- /content -->
    
    </div><!-- /main -->
    
    <?php get_footer(); ?>

    Can you try with the one above?

    <?php if(is_user_logged_in()): ?>
    
    here goes the content you want to show only to logged users
    
    <?php else:
    wp_die('Sorry, you must first log in to request a sample. You can register free here.');
    endif; ?>
    Thread Starter flameash

    (@flameash)

    thx for helping out.

    I tried your code, but still the same thing.

    Other pages like about, contact us are all fine except this one requires login.the backgrounds, headers are like aligning left. so weird…><

    Thread Starter flameash

    (@flameash)

    thx a lot for helping me here. i got it 5 mins ago

    it’s because this part

    <?php
    /**
     * @package WordPress
     * @subpackage Motion
     */
    /*Template Name: Subscribers Only */
    ?>

    this is wrong.

    see below is the correct one:

    <?php
    /**
     * @package WordPress
     * @subpackage Motion
     */
    /*Template Name: Subscribers Only */
    get_header(); ?>

    that’s why the whole background is messed up

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘css not working after defined new page template’ is closed to new replies.