Re: Different home pages for logged-in/logged-out users
Thank you! You guys have been of great help.
@Philip: I have done what you’ve said, exactly, but it seems like I can only make the code work if I edit header.php.
Here’s the code I used (I adapted the method you used in your first reply and second reply):
<?php if (is_user_logged_in()) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bp_page_title() ?></title>
<?php do_action( 'bp_head' ) ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php if ( function_exists( 'bp_sitewide_activity_feed_link' ) ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php _e('Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
<?php endif; ?>
<?php if ( function_exists( 'bp_member_activity_feed_link' ) && bp_is_member() ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php bp_displayed_user_fullname() ?> | <?php _e( 'Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_member_activity_feed_link() ?>" />
<?php endif; ?>
<?php if ( function_exists( 'bp_group_activity_feed_link' ) && bp_is_group() ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php bp_current_group_name() ?> | <?php _e( 'Group Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_group_activity_feed_link() ?>" />
<?php endif; ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> <?php _e( 'Blog Posts RSS Feed', 'buddypress' ) ?>" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> <?php _e( 'Blog Posts Atom Feed', 'buddypress' ) ?>" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class() ?> id="bp-default">
<?php do_action( 'bp_before_header' ) ?>
<div id="header">
<h1 id="logo">" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php bp_site_name() ?></h1>
<ul id="nav">
<li<?php if ( bp_is_front_page() ) : ?> class="selected"<?php endif; ?>>
" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?>
<?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
<li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
<?php if ( bp_is_active( 'groups' ) ) : ?>
<li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
<?php if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
<li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<?php endif; ?>
<?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
<li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<!--<?php wp_list_pages( 'title_li=&depth=1&exclude=' . bp_dtheme_page_on_front() ); ?>-->
<?php do_action( 'bp_nav_items' ); ?>
<!-- #nav -->
<div id="search-bar">
<div class="padder">
<form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
<input type="text" id="search-terms" name="search-terms" value="" />
<?php echo bp_search_form_type_select() ?>
<input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
<?php wp_nonce_field( 'bp_search_form' ) ?>
</form><!-- #search-form -->
<?php do_action( 'bp_search_login_bar' ) ?>
</div><!-- .padder -->
</div><!-- #search-bar -->
<?php do_action( 'bp_header' ) ?>
</div><!-- #header -->
<?php do_action( 'bp_after_header' ) ?>
<?php do_action( 'bp_before_container' ) ?>
<center>Network: The 7th Zone :: Home | Grand Theft Auto HQ | Hot Devil 666's HQ | Silent Fiona's HQ
</center><p>
<div id="container">
<?php } else { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bp_page_title() ?></title>
<?php do_action( 'bp_head' ) ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php if ( function_exists( 'bp_sitewide_activity_feed_link' ) ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php _e('Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
<?php endif; ?>
<?php if ( function_exists( 'bp_member_activity_feed_link' ) && bp_is_member() ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php bp_displayed_user_fullname() ?> | <?php _e( 'Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_member_activity_feed_link() ?>" />
<?php endif; ?>
<?php if ( function_exists( 'bp_group_activity_feed_link' ) && bp_is_group() ) : ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> | <?php bp_current_group_name() ?> | <?php _e( 'Group Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_group_activity_feed_link() ?>" />
<?php endif; ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> <?php _e( 'Blog Posts RSS Feed', 'buddypress' ) ?>" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> <?php _e( 'Blog Posts Atom Feed', 'buddypress' ) ?>" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class() ?> id="bp-default">
<?php do_action( 'bp_before_header' ) ?>
<div id="header">
<h1 id="logo">" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php bp_site_name() ?></h1>
<ul id="nav">
<li<?php if ( bp_is_front_page() ) : ?> class="selected"<?php endif; ?>>
" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?>
<?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
<li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
<?php if ( bp_is_active( 'groups' ) ) : ?>
<li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
<?php if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
<li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<?php endif; ?>
<?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
<li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
<?php endif; ?>
<!--<?php wp_list_pages( 'title_li=&depth=1&exclude=' . bp_dtheme_page_on_front() ); ?>-->
<?php do_action( 'bp_nav_items' ); ?>
<!-- #nav -->
<div id="search-bar">
<div class="padder">
<form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
<input type="text" id="search-terms" name="search-terms" value="" />
<?php echo bp_search_form_type_select() ?>
<input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
<?php wp_nonce_field( 'bp_search_form' ) ?>
</form><!-- #search-form -->
<?php do_action( 'bp_search_login_bar' ) ?>
</div><!-- .padder -->
</div><!-- #search-bar -->
<?php do_action( 'bp_header' ) ?>
</div><!-- #header -->
<center>Network: The 7th Zone :: Home | Grand Theft Auto HQ | Hot Devil 666's HQ | Silent Fiona's HQ
</center><p>
<div id="container">
<div id="content">
<div class="padder">
<div class="page" id="blog-page">
<h2 class="pagetitle">Welcome to the party!</h2>
<div class="post" id="post-68">
<div class="entry">
<p>Social networking at The 7th Zone is like partying! …and more! Joining in the fun at The 7th Zone is nothing like you’ve experienced on Facebook, MySpace, or any major social networking sites! Akin to a crazed, wild college party, The 7th Zone is where fun-loving youths, as well as video game enthusiasts and tech geeks can hang out!</p>
<p>Staying up late to snag that cool-sounding medal in Halo 3, or piloting that Annihilator helicopter in Grand Theft Auto IV’s Free Mode? Fancy that VAIO Z laptop, or are you going nuts over a MacBook Pro refresh? Think the iPad is gimmicky and expected so much more? Prefer metal over the Jonas brothers, and classic Hip Hop over auto-tuned sh*t? This site is for you, the cool kid!</p>
<p>Right here at The 7th Zone Community, you can create your own free blogs. With 500 MB of upload space, a feature-packed plugins set, and 117 beautiful themes, just how much more can you get for $0? More details here.</p>
<p>Join us now. Registration is as easy as a few clicks! Hit the jump below to register yourself!</p>
<div align="right">
<h2>Register Me! »</h2>
</div>
<p>Edit this entry.</p>
</div>
</div>
</div><!-- .page -->
<?php do_action( 'bp_after_blog_page' ) ?>
</div><!-- .padder -->
</div><!-- #content -->
<?php locate_template( array( 'sidebar.php' ), true ) ?>
<?php get_footer(); ?>
<?php } ?>
For some reason, my site still displays whatever page I’m on for non-logged in users, and it does so after the footer for the else case. I have no clue what I did wrong. I have no experience in PHP code, but it looks fine to me. Is there an error I made somewhere?
It also seems that if I set the activity stream to be the home page, the custom home page title that I’ve set in the All-in-One SEO pack doesn’t seem to take effect too. If I want to show logged in users the activity stream as the home page, with my custom home page title, how do I go about doing that?
Thanks.