Currently I have a header file checking to see if users are logged in, and then a "landing" page which allows them to view all the sites they have access to within my multisite network. This functionality is working great - but I can't seem to figure out how to prohibit them from manually entering the path to the subfolder if they do not have access to it (IE: User A has access to Sites A and B but not C - Currently you can still access it by typing in http://www.example.com/Subfolder-C/ path).

My code is below for header file, which I'm assuming is where I would be going to input the remaining code to prevent them from accessing the site without being a user on the multisite instance.

Template Name: Brand Home
<style type="text/css">
body {background-color:black;} 
<?php global $current_user;
if ( is_user_logged_in() ) {
<?php brand_login($current_user->ID); ?>

And then this is my functions.php code that deals with logins

add_filter( 'login_url', 'mysite_login_url', 10, 2);
function mysite_login_url( $force_reauth, $redirect ){
$login_url = '/';

if ( !empty($redirect) )
    $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );

if ( $force_reauth )
    $login_url = add_query_arg( 'reauth', '1', $login_url ) ;

return $login_url ;

$sitepath = array();

if(is_user_logged_in()) {
global $current_user;
$blogs = get_blogs_of_user( $current_user->id );
 if($blogs) {
     foreach ( $blogs as $blog ) {
        $blogpath = $blog->path;
         if ($blogpath == '/diesel/') {
         $sitepath[intval($blog->userblog_id)] = 'href="/diesel/" class="opaque" ';
         if ($blogpath == '/michael-kors/') { 
         $sitepath[intval($blog->userblog_id)] = 'href="/michael-kors/" class="opaque" ';
         if ($blogpath == '/marc-by-marc-jacobs/') { 
         $sitepath[intval($blog->userblog_id)] = 'href="/marc-by-marc-jacobs/" class="opaque" ';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.