• With my blog setup as

    http://hostname/blogname

    the redirect was calculating the URL as

    http://hostname/blogname/blogname/index.php

    I had to change the php code to the following for it to work at my site:

    $path = parse_url(get_bloginfo('url'),PHP_URL_SCHEME) . '://' . parse_url(get_bloginfo('url'),PHP_URL_HOST).$_SERVER['PHP_SELF'];

    that line is located here:

    <p><strong>Sorry!</strong> You must <a href="<?php bloginfo('url'); ?>/wp-login.php?redirect_to=<?php
    			$path = parse_url(get_bloginfo('url'),PHP_URL_SCHEME) . '://'.parse_url(get_bloginfo('url'),PHP_URL_HOST) . $_SERVER['PHP_SELF'];
    			echo $path;
    		?>&reauth=1">log in</a> to view this page.</p>

    http://ww.wp.xz.cn/extend/plugins/protected-site/

Viewing 1 replies (of 1 total)
  • Thread Starter valcorin

    (@valcorin)

    For those who just want all users who aren’t logged in directed to the login page, you can modify the plug-in to the following:

    <?php
    /*
    Plugin Name: Protected Site
    Description: Block users from accessing your blog or a specific blog in your network by activating this plugin on the blog you wish to protect.
    Author: Davo Hynds
    Version: 1.0
    Author URI: http://ashramcreative.com
    Modification: Code modified to redirect to the login page rather than requiring a click through
    */
    
    add_action( 'get_header', 'ac_protected_site' );
    function ac_protected_site() {
    	if ( !is_user_logged_in() ) {
    		$bigurl = home_url().'/wp-login.php?redirect_to=';
    		$path = parse_url(get_bloginfo('url'),PHP_URL_SCHEME).'://'.parse_url(get_bloginfo('url'),PHP_URL_HOST).$_SERVER['PHP_SELF'];
    		$bigurl = $bigurl.$path;
    		header( "Location: $bigurl" );
    	}
    }
    ?>
Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Protected Site] Double folder name’ is closed to new replies.