The release candidate of ViewLevel 2.0 is now available. This is a port of Kendra Burbank’s excellent ViewLevel plugin to WordPress 1.5.
There is a new options page for setting the default viewlevel. Filtering is now done at the SQL stage, so unprivileged users now see the top ten viewable posts. In Kendra’s version, the filtering was done in the loop, so sometimes casual viewers might not see any posts at all, even when they should have been able to.
ViewLevel 2.0 has now been released.
Latest version: 2.0.0
Released on: 25th August, 2005
Download it here: http://blog.firetree.net/wp-content/plugins/viewlevel20.zip
Read the latest documentation.
ViewLevel 2.0 is compatible with WordPress 126.96.36.199. No hacks or source code editing are required. If you have trouble, first make sure you are using the very latest WordPress code.
Please try this beta plugin, and let me know what you think. If you find a bug, then first check in the list below to see if it’s already been reported or fixed. If not, then please report it by posting a comment.
When posts have a custom field called Ã¢â‚¬Å“viewlevelÃ¢â‚¬Â set, only lets users with that user level or above see the post.
As a shortcut, you may add text like Ã¢â‚¬Å“vl=3Ã¢â‚¬Â³ into posts to set the viewlevel. (If you actually want to say “vl=3″ in your post, then use an ‘entity reference’ for the ‘=’, like this: “vl=3″.)
If you don’t set the viewlevel, then the post is assigned a default. You can set this default on the new ViewLevel Options page. To start with the default is ‘0’, so everyone will be able to see your posts.
Optional template change
If you want to mark restricted posts with the padlock icon, then change your
index.php so that the post title part looks like this:
<h2 class="posttitle" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark"> < ?php if(function_exists('vl_restricted'))vl_restricted(); the_title(); ?> </a> </h2>
The crucial part is the
if(function_exists('vl_restricted'))vl_restricted();. This calls the new
vl_restricted() template function if it exists.
vl_restricted() takes a couple of optional parameters that you can use to customise what it does. Read to code for further details.
Bugs so Far
- Doesn’t work! Low user level users get SQL errors, and can’t see any posts. Thanks to everyone who reported this problem. (fixed in rc2)