Support » Fixing WordPress » Create permissions for pages

  • How would I call a permission for a page or a category?
    Say I only want Admins, Authors and Editors to access a page/category but no contributors/subscribers or guests.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Andrew Ozz


    WordPress Dev

    Password-protect the posts/pages (with the same password)?

    See but that’s not a good answer to me as password protecting, especially with the same password, is unsafe. Also, what if I change an Author/Editor to a Contributor or Subscriber because of issues, Then I have to go through the hassle of changing the password for every post/page and then update every member that needs that password with the new password and there is no simple way for me to provide that other then email them.

    Unfortunately that is not a good solution.

    I think to describe this more clearly, I just need an If Then statement that I can add

    if (user_has_permission(‘publish_posts’));
    The Page
    Sorry you can’t access this

    I’ve tried it multiple times and each time it does nothing or it gives me SQL errors.
    As for the categories I’m either going to have to mod the admin and other code or something but I would need the same code that I’m using here to mod it I would assume.

    Andrew Ozz


    WordPress Dev

    I think you can use the “current_user_can()” function in your templates. Have a look here:

    That’s what I needed.

    If anyone else needs this for pages on their site:

    Template Name: Template Name
    //Only Authors and higher can read this page.
       if (current_user_can('publish_posts')) { ?>
    	<div id="content" class="narrowcolumn">
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    <?php     }
    //Tell the people that don't have access to this page that they do not have access.
    You don't have access to this page.
    <?php } ?>
    <?php get_footer(); ?>

    I’m curious if anyone has found a way to lock categories from unregistered users? The above blocks users from pages but not categories, is there a way to filter them from categories?

    I think it has something to do with making an array for the categories that would be something like:
    if (logged_in)
    $category=array(Category numbers);
    $category=array(Category numbers);

    thanks for the help locking pages, im gunna try it out.

    It would be really helpful if support for Category permission were added in future versions though.

    Im implementing WP as a tool for our organization to share news and ideas, and to draw public interest.

    It would be nice, and I think encourage greater participation by our staff, if it could additionally be used for discussion of company politics and more sensitive matters that we dont want the public to view.

    One idea would be to give the Author the option of setting (or possibly requesting) what groups are able to see their post.
    This way a lower lever user would have the ability to post something that could only be viewed by administrators, not his colleagues.
    ..Just a thought.

    Some sort of simple Category based permission would be great though.

    Send requests for the feature to WP!

    Hey Morrigan,
    Could you give a little more info on how to implement that code on a page? Im not much on programming or php. Does that need to be enclosed in some sort of html tag?
    thanks for the help

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Create permissions for pages’ is closed to new replies.