Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add custom member application fields as substitution variables for email messages from the OEIS Member Application Management
<?php
/*
Plugin Name: OEIS Member Application Management: Custom Substitution Variables
Plugin URI: https://eighty20results.com/paid-memberships-pro/do-it-for-me/
Description: Add custom, pre-defined Register Helper fields, as email substitution variables for the messages sent by the OEIS Member Application Management plugin
Version: 1.1
Requires at least: 4.9
Tested up to: 4.9.8
Author: Eighty / 20 Results by Wicked Strong Chicks, LLC <thomas@eighty20results.com>
Author URI: https://eighty20results.com/thomas-sjolshagen/
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
License: GPLv2 or later
* Copyright (C) 2018 Thomas Sjolshagen - Eighty / 20 Results by Wicked Strong Chicks, LLC
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
namespace E20R\Customizations\Custom_Filters;
use OEIS\Application_Management\Models\OEIS_Data;
/**
* Adds a defined Register Helper field as a substitution variable for the OEIS Member Application Management plugin
*
* @param array $keys_by_type
* @param int $msg_type
*
* @return array
*/
function oeisCustomSubstitutionVars( $keys_by_type, $msg_type ) {
// OEIS Member Application Management plugin isn't active...
if ( ! isset( OEIS_DATA::PEER_SUPPORT ) ) {
return $keys_by_type;
}
$types = array();
if ( empty( $type ) ) {
// No type(s) specified so add them all
foreach (
array(
OEIS_Data::PEER_SUPPORT,
OEIS_Data::MEMBER_SUPPORT,
OEIS_Data::MEMBER_COMMITTEE,
) as $msg_type
) {
$types[] = $msg_type;
}
}
// Type specified, but not as a list. Converting to a single element list
if ( ! is_array( $type ) ) {
$types[] = $type;
}
// Process all types and add variables for each of them
foreach ( $types as $msg_type ) {
/**
* TODO: To add/extend/change the list, add a new `$keys_by_type[ $msg_type ][] = '...';` line for the Register Helper field you need to include
*
* This will be available to _all_ notification types
*/
$keys_by_type[ $msg_type ][] = 'active_mbr_support_type';
$keys_by_type[ $msg_type ][] = 'current_mbr_sup_name';
$keys_by_type[ $msg_type ][] = 'current_mbr_sup_email';
$keys_by_type[ $msg_type ][] = 'ext_phys_1_sup_name';
$keys_by_type[ $msg_type ][] = 'ext_phys_1_sup_email';
$keys_by_type[ $msg_type ][] = 'ext_phys_2_sup_name';
$keys_by_type[ $msg_type ][] = 'ext_phys_1_sup_email';
}
return $keys_by_type;
}
add_filter( 'oeis_substitution_variable_names', 'oeisCustomSubstitutionVars', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.