Update: Please get the plugin from the wp-plugins.org repository. You can file bug reports there as well. It makes it a lot easier for me to manage the plugin’s development.
I was gonna call this plugin “Bouncer” but settled for a more explanatory name instead.
This plugin will allow only registered users of your blog to view the blog. If you have a wordpress powered blog that you don’t want your parents, or the secretary in your office, or the POTUS, to read it(okay, well, I can’t guarantee the last one
), then View source and save or Download the .zip file to start using it. This will effectively password protect your wordpress blog, and also prevent search engines from indexing the pages in the blog.
Instructions :
- Save the file registered_only.php to your wp-content/plugins folder
- Activate the plugin from the plugin administration page
- Relax
Usage Notes:
- If you really want your defense against unscrupulous readers to be strong, then disable the “Anyone can register” option in Options->General in your WordPress administration interface.
- If you want google and other search engines to be able to index your blog pages, then comment(add two // in the beginning of) the line
echo '<meta name="robots" content="noindex,follow" />';. This, however, would mean that the search engines might index your pages and if you want a “private” blog, then this would not be suitable, which is why is it uncommented by default. - If you are getting a “headers already sent” warning, then try adding the following one line to your .htaccess file (create a file called .htaccess if you don’t have one already) :
PHP_FLAG output_buffering on
This plugin is basically the auth.php file that ships with WordPress 1.2, adapted to fit needs, and is distributed under the GPL license.
opps …
<php?
ob_end_flush();
?>
sorry for any confusion.
Site administator please truncate all of these posts, delete most of the first one and just give my solution if you will be so kind.
I guess this explains why I couldn’t access your weblog earlier this evening! Thatnks for all your work on WordPress. I am in the process of moving from MT.
I apologize for the inconvenience caused. I like to test things out live before releasing them out into the wild
Thanks for stopping by.
Pingback: Weblog Tools Collection » Registered users only
Hi Carthik, wow! just what the doctor ordered. Now I can even get my wife to start a private blog
Great stuff man. Keep ‘em coming.
Pingback: scriptygoddess
Thank you for coming up with this plugin. I was looking for something like this when I first moved to WordPress a few months ago.
You’re welcome!
An option for admin moderation after sign-up and before allowing the user to view or post would be nice for really private blogs. Possible?
As it is, new users can view the posts. I suggest you take away the “Users can register themselves option” in the options interface, and then manually add users based on your needs. They could email you and then you could add them on. New users are created with level zero, and that gives them the privilege to read the blog, which is the minimum permission, taking that away would mean they are not a user, if you see what I mean
Hi there, thanks for the reply Carthik. Yeah, it kinda dawned on me later when I looked under Options.
May be I’m trying to create a restricted access while not shooing away from by removing the Register link and asking them to email me.
You see the problem with users is that they don’t like to be intimidated by asking the owner directly. They’d rather do it discreetly and so will the owner respond by allowing them (a kind of Yahoo! Groups concept if you know what I mean).
The application, btw, is actually not for a blog, but rather to an info portal (that will contain localized copy protected info) and will be served across continents on my company’s intra.
Thanks again. I can live with the current option, but, would still love to see that in feature (possibly). Cheers.
For some reason I’m getting a “Cannot modify header information – header already sent…” error and I’ve gone through every php file and made sure about all the the whitespace. Is there maybe something else I should take a look at? This is on a fresh install of WP (1.2) (cleaned PHP files, etc). After going through a bunch of Googled pages, the only thing I came across was information about HTML elements coming before the redirect, but I’m not sure if thats it and/or how to modify this. Thanks.
Ref URL: http://laneallen.com/journal/
I’m also getting this message. Any ideas?
Please check the plugin file if you had opened it for editing in any editor.
The usual problems are a blank line after the closing ?>, a space somewhere in the middle of <?php or ?>
My best guess is you might have opened it for editing in the the cpanel editing tool or some such web based text editor.
The Template editor tool in wordpress is really good, please use that to check this file for the spaces I mentioned.
To start with you could re-upload the .php plugin file in the zip download I have provided (instead of using the .phps saved and edited)
let me know if the problem still remains
I encountered the same problem as above, but when I attempted to fix it by making sure no spaces were present, I encountered another problem where only the plugin was being sent for display not the rest of the weblog (though the header problem was fixed).
ooh
i like the sound of this
i guess i must try it out…and read the comments too..
Im having the same header problem too. and i used the template editor tool and i found a black line after ?> in the .php pulgin from your zip which i straight uploaded it.
I deleted the blank line but the problem is still there. any other helps available?
btw, whats “a space somewhere in the middle of < ?php or ?>” mean?
I’ve tried several times to install this plugin (including installing an “unopened” version). All I get is:
Warning: Cannot modify header information – headers already sent by (output started at /home/.gam/symserv/symtym.com/wp/index.php:17) in /home/.gam/symserv/symtym.com/wp/wp-content/plugins/registered_only.php on line 63
Warning: Cannot modify header information – headers already sent by (output started at /home/.gam/symserv/symtym.com/wp/index.php:17) in /home/.gam/symserv/symtym.com/wp/wp-content/plugins/registered_only.php on line 64
Warning: Cannot modify header information – headers already sent by (output started at /home/.gam/symserv/symtym.com/wp/index.php:17) in /home/.gam/symserv/symtym.com/wp/wp-content/plugins/registered_only.php on line 65
Warning: Cannot modify header information – headers already sent by (output started at /home/.gam/symserv/symtym.com/wp/index.php:17) in /home/.gam/symserv/symtym.com/wp/wp-content/plugins/registered_only.php on line 66
Warning: Cannot modify header information – headers already sent by (output started at /home/.gam/symserv/symtym.com/wp/index.php:17) in /home/.gam/symserv/symtym.com/wp/wp-content/plugins/registered_only.php on line 72
I thought perhaps it was a CHMOD problem with registered_only.php with a CHMOD at 644, but changing it to 777 made no difference. Would like to try this out–because this is exactly the level of control I’m looking for. What am I doing wrong?
Could it be that you are using other plugins simultaneaously? Try turning the others off and activating this one to see if you still have a problem.
The headers already sent problem usually occurs when there is a white space somewhere. Other than these, there is nothing I can think of.
No other plugins running. I’m stumped. I reinstalled the index.php and changed back to the original wp-layout.css, and no change. For the plugin it says version 0.1. Is this the correct version number?
I’ve encountered the same error. I’ve looked for whitespace, turned off the “users register themselves” option, turned off all my plugins and tried and it still throws the header error.
I’m curious. Have you tested it with your website on a different browser? Reason I’m asking is because in my main browswer “firefox” I was still able to view my website, however, in IE, it was throwing the header error. Obviously the cookie was allowing me to see my website on firefox.
Just wondering if you view your website in a different browser, or anyone else who has this plugin working. Do you encounter this error?
Wow! This plug-in is GREAT! Easy & quick! Thank you! It’s exactly what I needed!
Hi Carthik, I installed WP 1.2 on one of my other domain’s. I uploaded the Registered Users plugin and activated it. I received the same header warning that some of the others (in the above comments) received. This is from a clean install of WP 1.2. The header warnings indicated that the headers were already sent by line 9 of index.php and that they were in conflict with lines 63-66, 72.
I took the liberty of looking at index.php that came with WP 1.2 and I noticed the following in between the <head> </head> :
<?php wp_head(); ?>
It was located right above the </head> tag. When I removed this line, the header warning disappeared from my site. It seems that this line was causing the problem. I don’t know how important it was to have that line in WP, but hopefully you can figure out why it was causing the error.
I hope this helps.
I just noticed that once I removed <?php wp_head(); ?> from my index.php, I was able to view the posts on my site – even when I was logged out. So I’m guessing that portion of code is needed.
wp_head is the hook that is used to activate or use the plugin, and that is required. Could it be possible that there are other plugins that you using that is causing the headers sent problem?
There must be something specific to your installation that is causing the problems. I am so sorry, it should have worked fine, like it has for so many others. I am stumped.
There are no other plugins activated on this installation of WP 1.2. I will try it again on another install.
Carthik, sorry I haven’t gotten back to you. I’ve been busy with offline life. I pulled the line < ?php wp_head();?> out like Ria mentioned and the error is gone. However, < ?php wp_head();?> is needed inside the head tags if you use the Show/Hide on same page plugin for the comments.
Like I said before, this plugin will not work without that line. Deleting that line is equivalent to turning off the plugin. I do not have access to a server which throws this error, yet. It works fine on 4 servers I have tried, and so, though I would love to get to the root of this, I am unable to.
I could give you access to the blog that I am setting up. Just e-mail me to let me know if you want to do that. Do you actually need access to the cpanel? Or will FTP and WP 1.2 login suffice?
Excellent! Works wonderfully now. Thank you!
Like I said before too
I managed to resolve the “headers already sent” problen by adding a .htaccess file with a line “PHP_FLAG output_buffering on” as instructed by Carthik. This file is at the blog’s root directory (e.g. http://mydomain.com/myblog/.htaccess). It works only for LINUX and Apache. Unfornately it does not work for WinNT and IIS. Anyone with suggestions on how to resolve this for WinNT and IIS?
wow! itz working now. finally…..thanks all.
is it compatible with blogspot?
Wow – does absolutely nothing
I’m curious as to why it wouldn’t be working at all on any level. My blog setup is in different directories (index.php on root level & wordpress in a renamed dir one level deeper).
I am not sure if wordpress has a problem with plugins on index.php getting enabled when the index is in a different directory. There is nothing in the plugin itself that depends on the location of index.php
I also got this header problem. .htaccess way doesn’t work since my server’s apache doesn’t support “PHP_FLAG output_buffering on”. After so many frustrating trying, I gave up and chose to hack the core a little bit. Basically wrap all HTML output before header is completely sent with ob_start() and ob_end_flush(). Here’s the modification I made to index.php: (looked for ADDED by TK)
< ?php
/* Don't remove this line. */
require('./wp-blog-header.php');
// ADDED by TK
ob_start();
// Ended ADDED by TK
?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@import url( < ?php echo get_settings('siteurl'); ?>/wp-layout.css );
sorry about that… here it is again
< ?php
/* Don't remove this line. */
require('./wp-blog-header.php');
// ADDED by TK
ob_start();
// Ended ADDED by TK
?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< ?php wp_get_archives('type=monthly&format=link'); ?>
< ?php //comments_popup_script(); // off by default ?>
< ?php wp_head(); ?>
< ?php
// ADDED by TK
ob_end_flush();
// ENDED by TK
?>
ah…. all right… in index.php, after line 2: require(‘./wp-blog-header.php’); add this
ob_start();
before closing < / head >, add
ob_end_flush();
Jim,
I followed the comments from post 24, and it has worked for me.
< ?php
/* Don't remove this line. */
require('./wp-blog-header.php');
ob_start();
?>
ob_end_flush();
Actually, I don’t know where to place “ob_end_flush();” but it seems to be working without this
ok with a bit more work …
I put this:
ob_start(); at the start of the first php coding about line two.
and I went all the way to the bottom of the index.php file and added at the bottom the following:
>php?
ob_end_flush();
?<
It is the last thing in the index.php file now … and it appears to work.
We’ll see if it takes this post. Post 24ish was the key, but I couldn’t quite figure out where to put this. I’ll now have to research a bit to figure out what the effect of this action is, but it appears to make this all work. I might add, that I used a plain text editor and have no trailing lines anywhere, so that wasn’t the problem.
Thank you very much – it was extremely helpful in making a private blog. Just teh right thing!
Pingback: Sweet August Dreams
I have been trying to install this plugin, but I am having an error.
Fatal error: Cannot redeclare verify_login() (previously declared in
/home/tinaj/public_html/wp-includes/functions-user.php:3) in
/home/tinaj/public_html/wp-content/plugins/registered_only.php on line 29
If I add to the .htaccess file I get a 500 internal error. So I have removed the plugin from my directory. I don’t know what I can do to fix this. Could it be because I am using WP 1.3-alpha-2?
Thank you!
Tina, yes, it appears that 1.3-a-2 also has a function called verify_login(), which is there in the plugin. You can get it to work by renaming all occurences of verify_login() in the plugin file, with some other function name, like RO_verify_login()
Coming to think of it, I think it is time I rewrote the plugin, since the verify_login functions seems to be in the core, as a seperate function now.
Thank you for the heads-up!
Thank you!!! I will try that.
Any new developments with the header errors problem? I’ve tried most or all of the solutions offered, but no dice. I don’t understand posts 22-24; where exactly should those lines be put in?
I might add, this is the latest stable version of WP, it works great without activation. As soon as I activate, then I get the error (when not logged in). There are no other plug-ins activated. Something is not quite right.