1

On a multisite installation, I have used the More Privacy plugin to limit access to a particular subsite www.example.com/privatesite . Other subsites are not private. This is working properly.

I have created a custom login page using https://codex.wordpress.org/Customizing_the_Login_Form information. All subsites use the same theme, so the custom login page code is in that Child Theme's functions.php file.

What is the best way to further customize my custom login form so that http://www.example.com/privatesite has a different login page than http://www.example.com/publicsite , even though all subsites use the same theme?

I suspect I will need some logic that will 'sense' the subsite being accessed.

Thanks.

Added: the final code used based on the approved answer

I took the checked answer from @hwl and used this function to get the blog name so it can be displayed on the custom login screen:

function get_the_blog_name() {
    $blog_id = get_current_blog_id();
    $blog_info = get_blog_details($blog_id);
    $blogname = $blog_info->blogname;
    return $blogname;
}

Thanks for the help!

1 Answer 1

1

You can get the current blog id (which would be the site in a network, your subsite) with get_current_blog_id() and you can get details of a particular site with get_blog_details()

from codex: get_blog_details(), passed an id of 1, may return the following object:

   [blog_id]      => 1
   [site_id]      => 1
   [domain]       => foo-multi-site.com
   [path]         => /site-path/
   [registered]   => 2014-07-31 14:51:09
   [last_updated] => 2014-07-31 15:51:56
   [public]       => 1
   [archived]     => 0
   [mature]       => 0
   [spam]         => 0
   [deleted]      => 0
   [lang_id]      => 0
   [blogname]     => Site Name
   [siteurl]      => http://foo-multi-site.com/this-site
   [post_count]   => 

If you don't pass an id to get_blog_details(), it calls get_current_blog_id() and uses that value.

So perhaps a conditional such as this:

$current_blog = get_blog_details();
if ( $current_blog->path === '/privatesite/' ) {
    //display log in or call template for private site
}
else {
    //do what you need for default log in
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.