A recent post on WordPress support forums asked if it were possible to restrict access to a WordPress post or page. I replied saying yes and suggested that the problem could be solved with a plugin. Well, it turned out to be a fun problem to contemplate, so here’s a rough first pass at that plugin. So far, no internationalization and no user-configurable error message; only post content is hidden (meaning that post title and comments, if any, are still visible to all). I am sure a lot of other nice things could be added, too, but the plugin seems to be functional and not dependent on version-specific features.
The installation is WordPress standard; download and unzip the restrict-to.zip file, create a restrict-to directory on your WordPress server under wp-content/plugins, put restrict-to.php into it, and activate the plugin using WordPress’ administrative interface.
To restrict access to a post or a page, put [restrict_to: user1, user2, user3] into the post or page in question, where user1, user2, user3 is a comma-separated list of users allowed to view the post or page (obviously, you can list as many or as few as you want, just don’t forget the commas). Users can be identified by their ID numbers or their login names (which will be handled in a case-insensitive fashion, so someuser, Someuser, and someUser will be perceived as identical).