Change WordPress user roles and capabilities › Forums › How to or FAQ › Change manage option capability
Tagged: #plugin-menu
- This topic has 5 replies, 2 voices, and was last updated 5 years, 8 months ago by Vladimir.
-
AuthorPosts
-
11/03/2019 at 10:08 #5565marketingasbParticipant
HI Vladimir,
I have a question currently I am using a table generator plugin, I want to allow users with the editor role to view this plugin menu on wp-admin.
I understand manage_options capability ONLY Allows certain role to edit this plugin menu
Hence, this is what I did on the plugin code .
class WPTG_Table_Generator {
public function __construct() {
$this -> add_roles_on_plugin_activation();
}public function add_roles_on_plugin_activation() {
add_role(‘editor’, ‘Editor’, array( ‘read’ => true, ‘edit_posts’
=> true ));
}
}Plugin’s index.php
require_once plugin_dir_path( __FILE__ ) . ‘inc/class-wptg-table-generator.php’;
function wptg_run_table_generator() {
$plugin_instance = new WPTG_Table_Generator(‘1.3.0’);
register_activation_hook( __FILE__, array($plugin_instance, ‘initialize’));
register_uninstall_hook( __FILE__, array(‘WPTG_Table_Generator’, ‘rollback’) );
}
I still cant get it to work.This is what I am suppose to see. http://prntscr.com/mw8kue
However, I can’t see it when I access wp admin as an editor.
Please do advise me, thank you.
12/03/2019 at 01:09 #5566VladimirKeymasterHi,
Share this TG plugin copy with support [at-sign] role-editor.com
I will look at its code to answer you, what is possible to do.2nd, alternative way, is to grant ‘manage_options’ to editor role, but use Admin menu access add-on to block admin menu items (like ‘Settings’, etc.), which are not needed to ‘editor’ role.
12/03/2019 at 01:16 #5567marketingasbParticipantHI Vladimir,
I don’t quite get you.
How do I grant manage_option this capability?
“Share this TG plugin copy with support [at-sign] role-editor.com”
And I don’t understand what does this mean? You mean you want me to share the source code of the plugin is it?
Thank you.
12/03/2019 at 01:19 #5568VladimirKeymasterYou can go to “Users->User Role Editor”, select “editor” role and turn ON the “manage_options” checkbox for it. Yes, editor role will get access to the many menu items, including “Settings”. But you can block other menu items with “Admin menu access” add-on.
Yes, I meant that you can share .zip of TG plugin source code with me via DropBox or similar service. I use such code for the investigation purpose and install locally only.
12/03/2019 at 03:45 #5569marketingasbParticipantHi Vladimir ,
Thanks for the Reply.
I think I found a solution. As long as add_menu_page has a manage_options parameter, we can go for each individual user role and tick on manage_options and that particular role will be added inside manage_options.
Is that correct?
Thank you.
12/03/2019 at 04:07 #5570VladimirKeymasterMore correct to say:
“role with ‘manage_options’ capability granted will get access to any admin menu item protected by ‘manage_options’ capability. Be careful, as ‘manage_options’ allows access to some critical menu items like “Settings”. -
AuthorPosts
- You must be logged in to reply to this topic.