Support » Plugin: WP Mail SMTP by WPForms » Allow Editors access to settings

  • Is there a way to allow editors to access the settings page?

    I have a site that I maintain where the client only has editor access that I have modified to allow them to also manage some things that only admin can usually manage.

    Is there a filter or anything that I can use to grant them access?

    The email password for the email they use for SMTP is automatically changed once per month. I need to be able to allow them to change the password and test.

    Thanks for your guidance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I dug through code and answered my own question, so you can consider this a feature request to add a hook to this plugin that allows altering the capability to access settings page. I’m of the opinion that this is something all plugins should have.

    Anyway, for anyone else that needs to do this here is a hack that will get it done.

    
    add_action('admin_menu', 'show_editor_smpt_settings_menu', 200);
    function show_editor_smpt_settings_menu() {
      // change capability for admin menu
      global $menu;
      foreach ($menu as $index => $item) {
        if ($item[2] == 'wp-mail-smtp') {
          $menu[$index][1] = 'edit_others_posts'; 
        }
      }
    }
    add_filter('user_has_cap', 'give_editor_smpt_settings_access', 10, 4);
    function give_editor_smpt_settings_access($allcaps, $caps, $args, $user) {
      // grant editors access to settings
      if (!isset($_GET['page']) || $_GET['page'] != 'wp-mail-smtp') {
        return $allcaps;
      }
      if (in_array('editor', $user->roles)) {
        $allcaps['manage_options'] = true;
      }
      return $allcaps;
    }
    
    • This reply was modified 4 months, 2 weeks ago by John Huebner.
    Plugin Support Gregor Capuder

    (@capuderg)

    Hi @hube2,

    sorry for this late reply…

    It looks like you’ve achieved what you wanted (adding ‘manage_options’ capabilities to your editors) 🙂

    Our plugin pages are requiring ‘manage_options’ capabilities because in the majority of cases the WP site admins are the ones that should be configuring these settings.

    I think you have an edge case with giving editors the access to edit plugin settings and you’ve also successfully resolved your issue with custom code.

    If there will be other users requesting this feature, we’ll take it into further consideration and make the capability filtrable.

    Have a nice day!

    You can call this an edge case if you choose. I don’t find this to be an edge case at all. This can be witnessed by the many plugins I use that give me the ability to alter who can have access to an their admin pages by simply providing a filter as well has the number of questions and answers on the internet about giving editors admin abilities in other areas of WP.

    
    $plugin_cap = apply_filters('plugin_name_cap', 'manage_options');
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.