WordPress.org

Ready to get started?Download WordPress

Forums

Make the blog private (9 posts)

  1. shanewhite42096
    Member
    Posted 2 years ago #

    I want a wordpress login page when you go to my site...for example

    It is a parent portal and when a parent goes to the site they type in the username and password the WHOLE CLASS has to access the site.

    Can this be done?

    Even if it is just a password, I'll be happy, but not fully satisfied.

    The parents need to feel it is more protected, and yes I know nothing is 100 percent protected online.

    BTW, I don't want to password protect every page, that gets annoying.

  2. Chandan Kumar
    Member
    Posted 2 years ago #

    Try the following code in under header.php file:

    if ( !is_user_logged_in() ) {
      wp_redirect( home_url('/wp-admin') );
      exit;
    }
  3. Chandan Kumar
    Member
    Posted 2 years ago #

    Try the following code in under header.php file:

    if ( !is_user_logged_in() ) {
      wp_redirect( home_url('/wp-admin') );
      exit;
    }
  4. shanewhite42096
    Member
    Posted 2 years ago #

    It didn't work...

  5. Chandan Kumar
    Member
    Posted 2 years ago #

    Try using the following function instead of wp_redirect:

    if ( !is_user_logged_in() ) {
      auth_redirect();
      exit;
    }
  6. shanewhite42096
    Member
    Posted 2 years ago #

    still didn't work, it displays the code on the webpage itself...here is the url: feastervilleschool.org/portal

  7. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    It matters where this code is entered in header.php, above please be more specific for OP.

    To better assist, shanewhite42096 should use pastebin to share the entire contents of his header.php file so that forum users can tell exactly where to place this code in the file.

  8. Try the More Privacy Options plugin to make your entire WordPress site login-only, or do a search for membership plugins (there are a ton of them) if you need to restrict access to certain pages or categories.

  9. shanewhite42096
    Member
    Posted 2 years ago #

    <!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 elegant_titles(); ?></title>
    <?php elegant_description(); ?>
    <?php elegant_keywords(); ?>
    <?php elegant_canonical(); ?>
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/css/colorpicker.css" type="text/css" media="screen" />
    
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold' rel='stylesheet' type='text/css'/>
    <link href='http://fonts.googleapis.com/css?family=Kreon:light,regular' rel='stylesheet' type='text/css'/>
    
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
    <!--[if lt IE 7]>
    	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie6style.css" />
    	<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/DD_belatedPNG_0.0.8a-min.js"></script>
    	<script type="text/javascript">DD_belatedPNG.fix('img#logo, span.overlay, a.zoom-icon, a.more-icon, #menu, #menu-right, #menu-content, ul#top-menu ul, #menu-bar, .footer-widget ul li, span.post-overlay, #content-area, .avatar-overlay, .comment-arrow, .testimonials-item-bottom, #quote, #bottom-shadow, #quote .container');</script>
    <![endif]-->
    <!--[if IE 7]>
    	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie7style.css" />
    <![endif]-->
    <!--[if IE 8]>
    	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie8style.css" />
    <![endif]-->
    
    <script type="text/javascript">
    	document.documentElement.className = 'js';
    </script>
    
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>
    
    </head>
    <body <?php body_class(); ?>>
    	<?php do_action('et_header_top'); ?>
    	<div id="container">
    		<div id="header" class="clearfix">
    			<a href="<?php bloginfo('url'); ?>">
    				<?php $logo = (get_option('chameleon_logo') <> '') ? get_option('chameleon_logo') : get_bloginfo('template_directory').'/images/logo.png'; ?>
    				<img src="<?php echo esc_url($logo); ?>" alt="<?php echo esc_attr(get_bloginfo('name')); ?>" id="logo"/>
    			</a>
    			<p id="slogan"><?php bloginfo('description'); ?></p>
    			<?php do_action('et_header'); ?>
    
    			<?php $menuClass = 'nav';
    			$menuID = 'top-menu';
    			$primaryNav = '';
    			if (function_exists('wp_nav_menu')) {
    				$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => $menuID, 'echo' => false ) );
    			};
    			if ($primaryNav == '') { ?>
    				<ul id="<?php echo esc_attr($menuID); ?>" class="<?php echo esc_attr($menuClass); ?>">
    					<?php if (get_option('chameleon_home_link') == 'on') { ?>
    						<li <?php if (is_home()) echo('class="current_page_item"') ?>><a href="<?php bloginfo('url'); ?>"><?php esc_html_e('Home','Chameleon') ?></a></li>
    					<?php }; ?>
    
    					<?php show_page_menu($menuClass,false,false); ?>
    					<?php show_categories_menu($menuClass,false); ?>
    				</ul> <!-- end ul#nav -->
    			<?php }
    			else echo($primaryNav); ?>
    
    			<div id="additional-info">
    				<div id="et-social-icons">
    					<?php
    						$et_rss_url = get_option('chameleon_rss_url') <> '' ? get_option('chameleon_rss_url') : get_bloginfo('comments_rss2_url');
    						if ( get_option('chameleon_show_twitter_icon') == 'on' ) $social_icons['twitter'] = array('image' => get_bloginfo('template_directory') . '/images/twitter.png', 'url' => get_option('chameleon_twitter_url'), 'alt' => 'Twitter' );
    						if ( get_option('chameleon_show_rss_icon') == 'on' ) $social_icons['rss'] = array('image' => get_bloginfo('template_directory') . '/images/rss.png', 'url' => $et_rss_url, 'alt' => 'Rss' );
    						if ( get_option('chameleon_show_facebook_icon') == 'on' ) $social_icons['facebook'] = array('image' => get_bloginfo('template_directory') . '/images/facebook.png', 'url' => get_option('chameleon_facebook_url'), 'alt' => 'Facebook' );
    						$social_icons = apply_filters('et_social_icons', $social_icons);
    						if ( !empty($social_icons) ) {
    							foreach ($social_icons as $icon) {
    								echo "<a href='" . esc_url($icon['url']) . "' target='_blank'><img alt='" . esc_attr($icon['alt']) . "' src='" . esc_url($icon['image']) . "' /></a>";
    							}
    						}
    					?>
    				</div>
    
    				<div id="search-form">
    					<form method="get" id="searchform" action="<?php echo home_url(); ?>/">
    						<input type="text" value="<?php esc_attr_e('Search this site...', 'Chameleon'); ?>" name="s" id="searchinput" />
    						<input type="image" src="<?php bloginfo('template_directory'); ?>/images/search_btn.png" id="searchsubmit" />
    					</form>
    				</div> <!-- end #search-form -->
    			</div> <!-- end #additional-info -->
    		</div> <!-- end #header -->

Topic Closed

This topic has been closed to new replies.

About this Topic