Description: Add more privacy(visibility) options to a WordPress Multisite Network. Settings->Reading->Visibility:Network Users, Blog Members, or Admins Only. Network Settings->Network Visibility Selector: All Blogs Visible to Network Users Only or Visibility managed per blog as default.
Author: D. Sader
Author URI: http://dsader.snowotherway.org/
Network: true
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/*
Tips:
To allow everyone who is on-campus into the blog, while requiring those off-campus to log in. Modify function ds_users_authenticator().
Second, allow activate.php on the main page, but PHP_SELF url string matching may have the same drawbacks as REQUEST_URI. Could be done to main page with a plugin/function.
Also, the appearance of wp-activate on a subsite depends on which action is hooked: send_headers, or template_redirect. I prefer the template_redirect so activations can occur on subsites, too.
Third, you could redirect any url match to the main page wp-activate.php, but the redirection doesn't take the activation key with it - just not ideal to use any site but the main for activation IMHO.
// at any rate using url matching was dumb - adding wp-activate.php to any url bypassed the login auth - so a redirect to main site may help - provided the main site isn't also private.
// if( strpos($_SERVER['REQUEST_URI'], 'wp-activate.php') && !is_main_site()) { //DO NOT DO THIS!
So, better may be PHP_SELF since we can wait for script to execute before deciding to auth_redirect it.
Finally, changing the hook to fire at send_headers rather than template_redirect allows the activation page on every site. Still shows template pages with headers/sidebars etc - so not ideal either. Hence my preference to redirect to the main site.
So, I have the private functions the way I actually use them on my private sites/networks. I also do many activations as the SiteAdmin manually using other plugins.
Therefore, the code in this revision may make blogs more private, but somewhat more inconvenient to activate, both features I desire.
We'll see how the feedback trickles in on this issue.
<inputtype='radio'name='option[blog_public]'value='-2'<?phpif($details->public=='-2')echo" checked"?>><?php_e('Site Members Only(-2)',$this->l10n_prefix)?>
<inputid="blog-private-1"type="radio"name="blog_public"value="-1"<?phpchecked('-1',get_option('blog_public'));?>/><?php_e('Visible only to registered users of this network',$this->l10n_prefix);?>
</label>
<br/>
<labelclass="checkbox"for="blog-private-2">
<inputid="blog-private-2"type="radio"name="blog_public"value="-2"<?phpchecked('-2',get_option('blog_public'));?>/><?php_e('Visible only to registered users of this site',$this->l10n_prefix);?>
</label>
<br/>
<labelclass="checkbox"for="blog-private-3">
<inputid="blog-private-3"type="radio"name="blog_public"value="-3"<?phpchecked('-3',get_option('blog_public'));?>/><?php_e('Visible only to administrators of this site',$this->l10n_prefix);?>
//December 2012 tested with "Free RSS" for iPhone. Google Reader does not authenticate locked feeds. Tough to find a free reader that does authenticate.
<p><ahref="<?phpif(!is_user_logged_in()){echowp_login_url();}else{echonetwork_home_url();}?>"><?phpecho__('Click',$this->l10n_prefix).'</a>'.__(' to continue',$this->l10n_prefix);?>.</p>
<?php$this->registered_members_login_message();?>
</form>
</div>
</body>
</html>
<?php
exit();
}else{
if(is_feed()){
$this->ds_feed_login();
}else{
auth_redirect();
}
}
}
}
functionregistered_members_login_message(){
global$current_site;
echo'<p>';
if(!is_user_logged_in()){
echo__('Visible only to registered users of this site',$this->l10n_prefix);
}
if(is_user_logged_in()){
echo__('To become a member of this site, contact',$this->l10n_prefix).' <a href="mailto:'.str_replace('@',' AT ',get_option('admin_email')).'?subject='.get_bloginfo('name').__(' Site Membership at ',$this->l10n_prefix).$current_site->site_name.'">'.str_replace('@',' AT ',get_option('admin_email')).'</a>';
}
echo'</p><br/>';
}
functionregistered_members_header_title(){
return__('Visible only to registered users of this site',$this->l10n_prefix);
}
functionregistered_members_header_link(){
return__('Visible only to registered users of this site',$this->l10n_prefix);