Manage access to MyMail – Email Newsletter Settings tabs

MyMail – Email Newsletter Plugin for WordPress” Settings page includes 14 tabs. Not all of these tabs are protected by different user capabilities. How to make available the different list of these tabs for different WordPress user roles? Let’s see it on example of hiding some tabs from non-administrator users.

“MyMail – Email Newsletter” plugin was written in respect to the general WordPress hooks concept and other developers. It offers very useful filter ‘mymail_setting_sections’. Let’s see how to use it for our purpose:

add_filter('mymail_setting_sections', 'manage_mymail_setting_sections', 10, 1);
function manage_mymail_setting_sections($sections) {

  if (current_user_can('administrator')) {
    return $sections;
  // unset($sections['general']); 		// General
  // unset($sections['frontend']);		// Frontend
  // unset($sections['subscribers']);		// Subscribers
  // unset($sections['wordpress-users']);	// WordPress Users'
  // unset($sections['forms']);			// Forms
  // unset($sections['texts']); 		// Texts
  // unset($sections['tags']);			// Tags
  // unset($sections['delivery']);		// Delivery
  // unset($sections['cron']);			// Cron
  unset($sections['capabilities']);		// Capabilities
  // unset($sections['bounce']);		// Bouncing
  // unset($sections['authentication');		// Authentication
  unset($sections['purchasecode']);		// Purchasecode
  unset($sections['system_info']);		// System Info
  $sections['wordpress-users'] = 'Users';
  return $sections;

With code above we removed “Capabilities”, “Purchasecode” and “System Info” tabs from the “Settings” page of plugin for all users except one with the “Administrator” role. In order to remove some other tab just delete the “//” PHP comment symbols before the correspondent line.

Pay attention to the line #24. As a bonus you may rename any tab, as we did with the “WordPress Users” tab. Look on the picture with result of our intervention below:

Modified Settings of MyMail - Email NewsLetter
Modified Settings page of the MyMail – Email Newsletter plugin for WordPress