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 can't get it to work.

Attached is what I am supposed to see but I am not seeing it when I access wp-admin using the user account with the editor role.

enter image description here

Please do advise me on this.

Thank you.

  • editor is an existing role. You can use add_cap() to add a capability (e.g. manage_options) to an existing role. – Sally CJ Mar 11 '19 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.