Allowing Other WordPress Roles to View or Manage Email Logs

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy but don’t provide support for code customizations or 3rd party development.

For a simple approach to adding custom code to your site, please see WPBeginner’s guide to using WPCode.

Overview

Would you like to provide access to your website’s other user roles to view or manage the email logs? Allowing access to other roles is a great way to ensure all incoming emails are read, and the outgoing emails are sent successfully.

Note: Be sure to install and activate the WP Mail SMTP plugin and turn on email logging on your site before adding the code snippet provided in this tutorial.

Setup

We recommend that you copy and paste the required snippet below into a new WPCode snippet. WPCode makes it easy and safe to run code snippets on your site.

For help with adding snippets to your site, please see our tutorial on adding code snippets using the WPCode plugin.

The capability manage_options is selected by default for viewing and managing email logs. On line 2, you can change this to any other capability of your choosing.

Be sure to check out the complete list of WordPress roles and capabilities.

View Email Logs
add_filter('wp_mail_smtp_admin_area_get_logs_access_capability', function (){
return 'manage_options';
});
Manage Email Logs
add_filter('wp_mail_smtp_pro_emails_logs_logs_get_manage_capability', function (){
return 'manage_options';
});

That’s it! Now you know how to successfully allow other WordPress roles to view or manage the email logs of your WordPress site.

Next, want to explore more ways to customize your WP Mail SMTP setup? Be sure to look at our other code snippets for more customization options.