Restricting Editors from Reordering or Adding New Pages
-
Since my manual is intended for people with Editor level access, I wanted my Help documents to only be editable by Administrators.
So I made the following modifications (see below). I wanted to make this hack available to anyone considering doing the same thing. I’d also like to suggest that the ability to do this become an option in the settings in future release — or even better, allow the ability to assign reading / editing permissions to various role levels.
It’d also be nice to have the ability to show certain pages (or a whole separate help manual) only to specific levels, thus giving you the ability to create a different help manual for Editors than what is available for Subscribers, etc.
I love this plugin, I’m just hoping for more features in the future. Thanks!
All the changes were made in /wp-help/templates/list-documents.php
In line 8, publish_pages, was changed to manage_options.
BEFORE:
<?php if ( current_user_can( 'publish_pages' ) ) : ?><a href="<?php echo admin_url( 'post-new.php?post_type=wp-help' ); ?>" id="cws-wp-help-add-new"><?php _ex( 'Add New', 'Button with limited space', 'wp-help' ); ?></a><a href="<?php echo admin_url( 'edit.php?post_type=wp-help' ); ?>" id="cws-wp-help-manage"><?php _ex( 'Manage', 'verb. Button with limited space', 'wp-help' ); ?></a><?php endif; ?>
AFTER:
<?php if ( current_user_can( 'manage_options' ) ) : ?><a href="<?php echo admin_url( 'post-new.php?post_type=wp-help' ); ?>" id="cws-wp-help-add-new"><?php _ex( 'Add New', 'Button with limited space', 'wp-help' ); ?></a><a href="<?php echo admin_url( 'edit.php?post_type=wp-help' ); ?>" id="cws-wp-help-manage"><?php _ex( 'Manage', 'verb. Button with limited space', 'wp-help' ); ?></a><?php endif; ?>
In line 22, $this->get_cap( ‘publish_posts’ ), was changed to manage_options.
BEFORE:
<ul<?php if ( current_user_can( $this->get_cap( 'publish_posts' ) ) ) { echo " class='can-sort' data-nonce='" . wp_create_nonce( 'cws-wp-help-reorder' ) . "'"; } ?>>
AFTER:
<ul<?php if ( current_user_can( 'manage_options' ) ) { echo " class='can-sort' data-nonce='" . wp_create_nonce( 'cws-wp-help-reorder' ) . "'"; } ?>>
- The topic ‘Restricting Editors from Reordering or Adding New Pages’ is closed to new replies.