Customizing mail tabs

The WP Issues CRM inbox will, without any customization, segregate any trained messages under the ‘Advocacy’ tab. The advocacy tab is so populated regardless of any further customization below.

WP Issues CRM allows you to further segregate messages into custom tabs based on whatever message content or header data you wish to parse. This requires creating a special purpose plugin. A simple example plugin that adds a ‘Social’ tab appears below. You may be able to go much further by referencing data in the spam filter headers created by the spam filter installed on your mail server.

Write the plugin php code and then place it within a .php file within a subdirectory of the wp-content/plugins directory of your site. This code will then be invoked in the message parsing process to assign a category to each message.

Sample code module:

<?php 
/**
Plugin Name: WP Issues CRM Sample Social Tab plugin
Plugin URI: http://example.com
Description: Sample code to demonstrate model for create custom tabs
Version: 0.1
Author: Will Brownsberger
Author URI: http://willbrownsberger.com
Text Domain: wp-issues-crm
License: Not Licensed
License URI: Not Licensed
Text Domain: wp-issues-crm
*
NOTE THAT HEADERS AS ABOVE ARE NECESSARY FOR WORDPRESS TO ALLOW YOU TO ACTIVATE THE PLUGIN
*
*
*/

// category filter hook -- hooks your function into the parsing process for WP Issues CRM
add_filter( 'wp_issues_crm_local_category_filter', 'social_mail_filter', 10, 3 );

// category filter
function social_mail_filter( $category, $email_object, $constituent_id ) {

// list social domains
$group_social = array (
'facebook.com',
'twitter.com',
'linkedin.com',
'mail.instagram.com',
'meetup.com',
'rs.email.nextdoor.com',
'eventbrite.com',
);
if ( in_array( $email_object->from_domain, $group_social ) ) {
return 'CATEGORY_SOCIAL';
}
// default if not social
return 'CATEGORY_GENERAL';
}

/*
* local_tab_definition() is called when inbox produced
* tab names must correspond to category names --
* as 'General' corresponds to 'CATEGORY_GENERAL'
*/
function local_tab_definition() {
$tabs_array = array(
  'General',
  'Advocacy',
'Social', );
  return $tabs_array;
}

Leave a comment

Your email address will not be published. Required fields are marked *