Jump to content
xisto Community
Sign in to follow this  
dodgerblue

Wordpress 1.5 - Restricting Single Posts Without having to enter a password for each post

Recommended Posts

This is a mini tutorial on how to tweak WordPress 1.5 so that anonymous readers or registered users below a certain level (set by you) cannot view posts that you want to hide from them.

They won't even know that the posts exist.

This is assuming that either
1. you are running a blog/site that is meant to be administered by only one person (ie, you).
OR 2. you want to let some people co-author with you, but still need some posts to be restricted (more of a bloggers' privacy issue).

First Step: Download the Post Levels Plugin from http://forums.xisto.com/no_longer_exists/

Second Step: Extract it somewhere and install it into your blog's wp-content/plugins folder.

Third Step: Go to your blog dashboard's Site Admin > Users > Authors & Users interface.

Here you will see a list of Authors and registered Users.

If you are familiar with WP, you will know that the list of people under Users are those that have registered. The default level for Users is 0.

This plugin works (as outlined in the documentation/readme) by entering "post_level" as the password for each post you wish to restrict by user level.

You will have to promote the users that you want to see the restricted post.

If you want only registered users to view certain posts, then promoting all to level 1 will suffice.

If you want different groups of registered users to view different restricted posts - for example, you want Peter to view Post A and B but Jane to view only Post A, then promote Peter to level 2, and Jane to level 1, and so on.

However, installing this plugin and using it straight off alone is kind of dangerous if your blog/site is meant to be administered only by you, as the default user level for enabling editing of posts, pages and links is 1.

After promoting you can see that all users with a level higher than 0 are automatically transferred to the Authors section.

You must therefore change the edit level value manually.

Fourth Step: You must edit the menu.php file located in the wp-admin folder of your blog/site.

Edit only the number in the round brackets " ( " and " ) ".

For example, this line - $menu[5] = array(__('Write'), 5, 'post.php');

Edit the highlighted number. This will correspond with the level of the user. Ie, 5 means that only users with level 5 and above can post.

This is a sample of what mine looks like after editing:
 



$menu[0] = array(__('Dashboard'), 0, 'index.php');$menu[5] = array(__('Write'), 5, 'post.php');$menu[10] = array(__('Manage'), 5, 'edit.php');$menu[20] = array(__('Links'), 5, 'link-manager.php');$menu[25] = array(__('Presentation'), 8, 'themes.php');$menu[30] = array(__('Plugins'), 8, 'plugins.php');$menu[35] = array(__('Users'), 0, 'profile.php');$menu[40] = array(__('Options'), 5, 'options-general.php');

and
 



$submenu['post.php'][5] = array(__('Write Post'), 6, 'post.php');$submenu['post.php'][10] = array(__('Write Page'), 6, 'page-new.php');$submenu['edit.php'][5] = array(__('Posts'), 6, 'edit.php');$submenu['edit.php'][10] = array(__('Pages'), 6, 'edit-pages.php');$submenu['edit.php'][15] = array(__('Categories'), 6, 'categories.php');$submenu['edit.php'][20] = array(__('Comments'), 6, 'edit-comments.php');$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 1, 'moderation.php');$submenu['edit.php'][30] = array(__('Files'), 8, 'templates.php');$submenu['link-manager.php'][5] = array(__('Manage Links'), 5, 'link-manager.php');$submenu['link-manager.php'][10] = array(__('Add Link'), 5, 'link-add.php');$submenu['link-manager.php'][15] = array(__('Link Categories'), 5, 'link-categories.php');$submenu['link-manager.php'][20] = array(__('Import Links'), 5, 'link-import.php');$submenu['profile.php'][5] = array(__('Your Profile'), 0, 'profile.php');$submenu['profile.php'][10] = array(__('Authors & Users'), 5, 'users.php');$submenu['options-general.php'][5] = array(__('General'), 6, 'options-general.php');$submenu['options-general.php'][10] = array(__('Writing'), 6, 'options-writing.php');$submenu['options-general.php'][15] = array(__('Reading'), 6, 'options-reading.php');$submenu['options-general.php'][20] = array(__('Discussion'), 6, 'options-discussion.php');$submenu['options-general.php'][25] = array(__('Permalinks'), 6, 'options-permalink.php');$submenu['options-general.php'][30] = array(__('Miscellaneous'), 6, 'options-misc.php');

This effectively tells WP not to allow users below level 5 to edit anything except their own profiles, and users with level 6 and above can post and edit entries, pages and links, and users with level 8 and above can install and edit themes and plugins.

Hope this helped somewhat.. :( I'm available by IM and PM, as always.

Cheers!



Share this post


Link to post
Share on other sites

IMPORTANT UPDATE:This will NOT work with the newest version of WordPress (which is 1.5.1).It is recommended to update your WP as there are critical security fixes in 1.5.1If you've modified the menu.php file, it will be OVERWRITTEN during upgrade.Please remember to DEACTIVATE this plugin BEFORE you upgrade or it could mess up your entire installation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.