setTimeout(function () { window.location.assign('$url') }, 3600);"; return $confirmation; } /** * Fix GravityForms - Redirect form after save to setting in 'Confirmation' (not working in form). */ add_action( 'gform_after_submission_20', 'redirect_to_page', 10, 2 ); add_action( 'gform_after_submission_21', 'redirect_to_page', 10, 2 ); function redirect_to_page( $entry, $form ) { // Set the path for the redirection. switch($entry['form_id']) { case '20' : $location = '/sales-items/'; break; case '21' : $location = '/edit-payment-records/'; break; default : $location = '/'; } header('Location: '.$location); } /** * Create a button to edit/view a form via a post. */ // Get a link for the listing. function getRecordLink($id,$mode,$label,$link) { return("
". "". "". "". "
" ); } /** * Load the parents style sheet. */ add_action( 'wp_enqueue_scripts', 'total_child_enqueue_parent_theme_style' ); function total_child_enqueue_parent_theme_style() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', [], wp_get_theme( 'Total' )->get( 'Version' ) ); } /** * Define the dynamic filters to pass to Ninja Tables for the WHERE clause of a query. */ add_filter('ninja_table_raw_sql_placeholders', function ($value) { // Save the number along with the parameters to be passed. $value['{unitName}'] = (isset($_REQUEST['unitName'])) ? $_REQUEST['unitName'] : ''; $value['{memberNum}'] = (isset($_REQUEST['memberNum'])) ? $_REQUEST['memberNum'] : ''; return($value); }); /** * Display the elected State Officers on the Officer's page. */ function displayOfficers($query) { // Get the names of the men in office. $result = getDbObject()->dbQuery($query); // Build the officers section. $buffer = '
'; foreach ($result as $officer) { $buffer .= "
"; $buffer .= $officer['one']."
".$officer['two']; $buffer .= "
"; } $buffer .= "
"; // Display results. return($buffer); } /** * Display the Chapter Presidents on the Officer's page. */ function directorsAndMembership($officeAbbr,$title) { // Get the list of members. $officerList = getDbObject()->dbQuery( "SELECT b.fullName ". "FROM wp_sar_officerList a, wp_sar_currentMembers b ". "WHERE a.officeAbbr = '$officeAbbr' and a.nationalNum = b.nationalNum ". "ORDER BY last, first, middle, suffix" ); // Are there any entries to add? if (sizeof($officerList) > 0) { // Format the title. $title = "
$title
"; // Add the names. foreach($officerList as $name) $title .= $name['fullName']."
"; } return($title); } /** * Determine the date the rotationals end on the Officer's page. */ function computeYear($offset) { $year = (date("m") < '3') ? date("Y") : (date("Y") + 1); return($year + $offset); } /** * Add a user to WordPress. */ function addUserToWordpress($first,$last,$generalNum,$email,$password,$zip) { // Can we create the user? $id = wp_create_user( $generalNum, $password, $email); if (!is_wp_error($id)) { // Can we add metadata to the account? $status = wp_update_user(array( 'ID' => $id, 'user_nicename' => $generalNum, 'display_name' => $first." ".$last, 'user_status' => 0, 'first_name' => $first, 'last_name' => $last, 'role' => 'subscriber', 'meta_input' => array( 'user_password' => $password, 'user_zip' => $zip ) )); } // Did an error occur? if (is_wp_error($id) || is_wp_error($status)) error_log("addUserToWordpress: ".print_r($id->get_all_error_data(),true)."User/Email: ".$generalNum."/".$email,1,G_WEBMASTER_EMAIL); return($status); } /** * Add a record to a form in the Gravity Forms' database. */ // Add the fields of the associative array to a new entry in Gravity Forms. function addGfEntry($form,$fieldArray) { // Built a new template. $newEntry = array( "form_id" => "", "date_created" => date("Y-m-d")." 00:00:00", "is_starred" => "0", "is_read" => "0", "ip" => "::1", "source_url" => "https://www.masssr.org/", "currency" => "USD", "created_by" => "1", "user_agent" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0", "status" => "active" ); // Add the date created and form identifier. $newEntry['date_created'] = date("Y-m-d H:m:s"); $newEntry['form_id'] = $form; // Add the data fields for the record. foreach($fieldArray as $key => $value) $newEntry[$key] = $value; // Add the record to the database. $entry_id = GFAPI::add_entry($newEntry); return($entry_id); } /** * Add transaction number to Authorize.net charge to the payment transaction. */ add_filter('gform_authorizenet_transaction_pre_capture', function( $transaction, $form_data, $config, $form, $entry ) { if ( $form['id'] == '25' ) { $transaction->invoice_num = rgar($entry,GF_TX_INVOICE_NUM_FIELD); $transaction->cust_id = rgar($entry,GF_TX_CUSTOMER_NUM_FIELD); } return $transaction; }, 10, 5 ); /** * Add line items to Authorize.net submission object before transaction is sent. */ add_filter( 'gform_submission_data_pre_process_payment_25', 'modify_submission_data_25', 10, 4); function modify_submission_data_25( $submission_data, $feed, $form, $entry ) { // Parse itm string to create an array of line items. $line_items = array(); $items = explode("<||>",rgar($entry,'38')); // Are there any items? if (sizeof($items) > 0) { // Repack each item in a collection of associative arrays foreach ($items as $item) if (strlen($item) > 10) { $pieces = explode("<|>",$item); $line_items[] = array( 'id' => $pieces[0], 'name' => $pieces[1], 'description' => $pieces[2], 'quantity' => $pieces[3], 'unit_price' => $pieces[4], 'options' => '' ); } // Replace the line items field in the submission. $submission_data['line_items'] = $line_items; } return($submission_data); } /** * TEMPORARY PROCEDURE FOR GUEST FORM. DELETE AFTER EVENT xxx */ add_filter( 'gform_field_validation_31_6', 'custom_validation_quantity', 10, 4 ); function custom_validation_quantity ( $result, $value, $form, $field ) { if ($result['is_valid'] && $_POST['input_6_3'] < '1') { $result['is_valid'] = false; $result['message'] = 'Quantity must be one or more'; } return $result; } /** * TEMPORARY PROCEDURE FOR GUEST FORM. DELETE AFTER EVENT xxx */ add_filter( 'gform_field_validation_31_9', 'custom_validation_national_number', 10, 4 ); function custom_validation_national_number( $result, $value, $form, $field ) { // Is there a member for the national number? $member = getDbObject()->dbQuery( "SELECT COUNT(*) as 'count' FROM wp_sar_currentMembers WHERE nationalNum = '".$_POST['input_9']."'" ); if ($result['is_valid'] && $member[0]['count'] == 0) { $result['is_valid'] = false; $result['message'] = 'No member found for national number'; } return $result; } /* * Do the national number and its confirmation match on 'update national number' form? */ add_filter( 'gform_field_validation_11_4', 'custom_validation', 10, 4 ); function custom_validation( $result, $value, $form, $field ) { // Do number and confirmation match? if ($result['is_valid'] && $_POST['input_3'] != $_POST['input_4']) { $result['is_valid'] = false; $result['message'] = 'New number does not match its confirmation'; } else { // Does member with national number already exist? $member = getDbObject()->dbQuery( "SELECT * FROM view_sar_get_membership_records WHERE nationalNum = '".$_POST['input_4']."'" ); // Flag error if so. if (sizeof($member) > 0) { $result['is_valid'] = false; $result['message'] = 'Member with national number already exists'; } } return $result; } /** * Change national number of member in membership record, and in the sales records on 'update national number'. */ add_action( 'gform_post_submission_11', 'update_national_number', 10, 2 ); function update_national_number( $entry, $form ) { // Update the general number if both arguments supplied. getDbObject()->dbQuery( "CALL sproc_sar_update_national_number('".$_POST['input_1']."','".$_POST['input_4']."')" ); } /** * Change user password - Does password and confirmation agree? Make change if so. */ add_filter( 'gform_field_validation_22_5', 'updateMemberPassword', 10, 4 ); function updateMemberPassword($result,$value,$form,$field ) { // Does the number and confirmation match? Reset password if so. if ($_POST['input_4'] != $_POST['input_5']) { $result['is_valid'] = false; $result['message'] = 'Password and conformation mismatch'; } else wp_update_user(array('ID' => $_POST['input_1'], 'user_pass' => $_POST['input_4'])); return($result); } /** * Update the roster of officers/members when a state or chapter officer changes. */ add_action( 'gform_after_submission_9', 'updateListOfOfficers', 10, 2 ); add_action( 'gform_after_submission_8', 'updateListOfOfficers', 10, 2 ); function updateListOfOfficers( $entry, $form ) { // Update the list of officers. getDbObject()->dbQuery( "CALL sproc_sar_create_officer_list();" ); // Update the highest office held in the membership records. getDbObject()->dbQuery( "CALL sproc_sar_set_highest_office()" ); } /** * Update the modified payment record after editing. */ add_action( 'gform_after_submission_21', 'update_payment_record', 10, 2 ); function update_payment_record( $entry, $form ) { $result = getDbObject()->dbQuery( "UPDATE wp_sar_salesPayments ". "SET nationalNum = '".$_POST['input_1']."' ". " amount = '".$_POST['input_8']."' ". " first = '".$_POST['input_3.3']."' ". " last = '".$_POST['input_3.6']."' ". " address = '".$_POST['input_7.1']."' ". " city = '".$_POST['input_7.3']."' ". " state = '".$_POST['input_7.4']."' ". " zip = '".$_POST['input_7.5']."' ". " phone = '".$_POST['input_5']."' ". " email = '".$_POST['input_4']."' ". " checkNum = '".$_POST['input_10']."' ". " dateOfCheck = '".$_POST['input_11']."' ". "WHERE invoiceNum = '".$_POST['input_2']."'" ); } /** * Add the check payment for the purchase to the purchases table. */ add_action('gform_after_submission_26', 'record_check_payment', 10, 2 ); function record_check_payment( $entry, $form ) { getDbObject()->dbQuery( "CALL sproc_sar_record_check_payment('".date("Y-m-d")."','".$entry['id']."')" ); } /** * Update life memberships when one is changed. */ add_action( 'gform_after_submission_18', 'updateLifeMembers', 10, 2 ); function updateLifeMembers( $entry, $form ) { // Gather the entry-ids of the records to update. $result = getDbObject()->dbQuery( "SELECT d.entryId, c.natLife, c.stateLife ". "FROM ( ". " SELECT ". " MAX(IF(meta_key='1',meta_value,'')) as 'nationalNum', ". " MAX(IF(meta_key='4',meta_value,'')) as 'natLife', ". " MAX(IF(meta_key='6',meta_value,'')) as 'stateLife' ". " FROM wp_gf_entry a, wp_gf_entry_meta b ". " WHERE a.form_id = '26' and a.id = b.entry_id and a.status = 'active' ". " GROUP BY b.entry_id ". ") c, wp_sar_currentMembers d ". "WHERE c.nationalNum = d.nationalNum" ); // Update the life-membership fields. foreach($result as $member) { GFAPI::update_entry_field($member['entryId'],"77",$member['natLife']); GFAPI::update_entry_field($member['entryId'],"79",$member['stateLife']); } // Return to the life membership page. header('Location: /life-memberships/'); } /** * Add new candidate to membership roster. */ function addCandidateToRoster($mapping) { // Update the fields for which data is provided. $newCandidateArray = array(); foreach($mapping as $key => $value) if (isset($_POST[$key])) $newCandidateArray[$value] = $_POST[$key]; // Add salutation, type of member, and type of application. $newCandidateArray['28.2'] = 'Mr.'; $newCandidateArray['29'] = 'Candidate'; $newCandidateArray['35'] = 'Type of applicant: '.$_POST['input_10'].'; Related to member: '.$_POST['input_7']; // Add candidate to roster of members. addGfEntry("6",$newCandidateArray); } // Add candidate referred by member. add_action( 'gform_after_submission_2', 'add_member_referred_candidate', 10, 2 ); function add_member_referred_candidate( $entry, $form ) { // Form 2 to Form 6 field mapping. $mapping = array( "input_1_3" => "28.3", "input_1_6" => "28.6", "input_2" => "6", "input_3" => "56", "input_15" => "64", ); // Add candidate to roster. addCandidateToRoster($mapping); } // Add candidate applied from public website. add_action( 'gform_after_submission_10', 'add_candidate_from_public_website', 10, 2 ); function add_candidate_from_public_website( $entry, $form ) { // Form 10 to Form 6 field mapping. $mapping = array( "input_3_3" => "28.3", "input_3_6" => "28.6", "input_5" => "6", "input_24_1" => "2.1", "input_24_2" => "2.2", "input_24_3" => "2.3", "input_24_4" => "2.4", "input_24_5" => "2.5", "input_15" => "56", "input_6" => "82", ); // Add candidate to roster. addCandidateToRoster($mapping); } /** * Lookup the emails, name, and officers of a chapter to recieve a request for an award or medal. */ add_action( 'gform_pre_submission_12', 'award_pre_submission_handler' ); add_action( 'gform_pre_submission_13', 'award_pre_submission_handler' ); add_action( 'gform_pre_submission_14', 'award_pre_submission_handler' ); function award_pre_submission_handler( $form ) { // Fields on eagle/ROTC/public-service forms with emails, name, and officers of chapter with state chair. $mappings = array( '12' => array('zip' => '35_5', 'emails' => '30', 'chairName' => '40', 'chapName' => '25', 'stateChair' => 'XESC'), // Eagle Scout '13' => array('zip' => '41_5', 'emails' => '40', 'chairName' => '45', 'chapName' => '25', 'stateChair' => 'XROTC'), // ROTC '14' => array('zip' => '33', 'emails' => '44', 'chairName' => '46', 'chapName' => '38', 'stateChair' => 'XROTC'), // Public Service ); // Identify the chapter for the zip code. $chapter = getDbObject()->dbQuery( "SELECT chapter FROM wp_sar_zipCountyRef WHERE zip = '".substr($_POST['input_'.$mappings[$form['id']]['zip']],0,5)."'" ); // Get the emails of the target officer. $details = getDbObject()->dbQuery( "SELECT GROUP_CONCAT(c.email SEPARATOR ',') as 'emails', MAX(c.fullName) as 'chairName', MAX(c.chapName) as 'chapName' ". "FROM ( ". " SELECT email, NULL as 'fullName', NULL as 'chapName' ". " FROM view_sar_get_all_officer_roster ". " WHERE officeAbbr = '".$mappings[$form['id']]['stateChair']."' ". " UNION ". " SELECT DISTINCT a.email, a.fullName, b.chapName ". " FROM view_sar_get_all_officer_roster a, wp_sar_chapterRef b ". " WHERE a.chapAbbr = '".$chapter[0]['chapter']."' AND officeAbbr in ('CAAM','CPRES') AND a.chapAbbr = b.chapAbbr". ") c;" ); // Add emails and name of chapter and their A&M chairman to form. $_POST['input_'.$mappings[$form['id']]['emails']] = $details[0]['emails']; $_POST['input_'.$mappings[$form['id']]['chairName']] = $details[0]['chairName']; $_POST['input_'.$mappings[$form['id']]['chapName']] = $details[0]['chapName']; } /** * Enter a member's change of address into his membership record (Form 9 --> Form 3). */ add_action( 'gform_after_submission_7', 'change_of_address_update', 10, 2 ); function change_of_address_update( $entry, $form ) { // Form 9 to Form 3 field mapping. $mapping = array( "input_1_1" => "2.1", "input_1_2" => "2.2", "input_1_3" => "2.3", "input_1_4" => "2.4", "input_1_5" => "2.5", "input_1_6" => "2.6", "input_3" => "6", "input_4" => "56", "input_5" => "32", "input_6" => "31", "input_9" => "82" ); // Is the entry_id provided? if (isset($_POST['input_8']) && is_numeric($_POST['input_8'])) { // Update the fields for which data is provided. foreach($mapping as $key => $value) if (isset($_POST[$key])) GFAPI::update_entry_field($_POST['input_8'],$value,$_POST[$key]); // Update the change in the membership record in to relational table. getDbObject()->dbQuery( "CALL sproc_sar_load_gf_member_to_mysql($_POST['input_8'])" ); } } /* * Test 'redirect' custom field when entering a page. Redirect if not logged in. */ add_action('template_redirect', 'verify_authentication'); function verify_authentication() { $id = get_queried_object_id(); if (!is_user_logged_in() && get_post_meta( $id, 'mef_redirect', true ) == "true") { auth_redirect(); exit; } } /* * On successful login, redirect to the URL specified by custom login form. */ add_action('wp_login', 'on_login_redirect', 10, 3); function on_login_redirect( $user_login, $user ) { if (isset($_REQUEST['redirect_to']) && strlen($_REQUEST['redirect_to']) > 0) wp_redirect($_REQUEST['redirect_to']); else wp_redirect( home_url() ); exit; } /** * On failed login, redirect user to login page. */ add_action( 'wp_login_failed', 'myprefix_redirect_after_login_fail' ); function myprefix_redirect_after_login_fail( $username ) { wp_redirect('/login'); exit(); } /** * Redirect user to the home page when user logs out. */ add_action('wp_logout','auto_redirect_after_logout'); function auto_redirect_after_logout(){ wp_redirect( home_url() ); exit(); } /** * Always direct users to the theme's login page. */ add_filter( 'login_url', 'new_login_page', 10, 3 ); function new_login_page( $login_url, $redirect, $force_reauth ) { $login_page = home_url( '/login/' ); return add_query_arg('redirect_to', $redirect, $login_page ); } /** * This function looks for the current users national number and email in the wp_User object. */ function getNationalNumberFromWordpress(&$number,&$email,&$password,&$zip) { $number = "0"; $email = ""; $login = ""; $zip = ""; // Does the current user exist? $current_user = wp_get_current_user(); if ($current_user->exists()) { // Get the General Number (not "-X" sufix) and email. $number = substr($current_user->user_nicename,0,6); $email = $current_user->user_email; // Is this a member's account? if (is_numeric($number)) { // Get member's login and zip. /* xxx $password = get_user_meta($current_user->ID,"user_password",false)[0]; $zip = get_user_meta($current_user->ID,"user_zip",false)[0]; */ $password = get_user_meta($current_user->ID,"user_password",false); $zip = get_user_meta($current_user->ID,"user_zip",false); } } } /** * Returns TRUE if the user is has privledges above subscriber. */ function is_user_privledged($stringOfRoles) { // Is the user logged in? $status = FALSE; if (is_user_logged_in()) { // Get reference to user. Split string into array of roles. $currentUser = wp_get_current_user(); $roleArray = explode(",",$stringOfRoles); // Is any privledge in the user's roles? foreach($roleArray as $role) if (in_array(trim($role),$currentUser->roles)) $status = TRUE; } return($status); } /** * Set the directory where files are uploaded by Gravity Forms. */ add_filter( 'gform_upload_path', 'change_scwma_upload_path', 10, 2 ); function change_scwma_upload_path( $path_info, $form_id ) { $path_info['path'] = G_UPLOAD_PATH; $path_info['url'] = G_UPLOAD_URL; return $path_info; } /** * Performs a query and places the result set in a form for a Gravity Forms * drop-down control. */ function buildDropdownList($query,$message = "") { // Create array for drop down. Start with blank item. $items = array(); $items[] = array( 'value' => '0', 'text' => $message, 'selected' => 'selected'); // Get the values for the dropdown. $result = getDbObject()->dbQuery($query); // Add the element to the dropdown. foreach ($result as $item) $items[] = array( 'value' => $item['value'], 'text' => $item['text']); // Assign the list to the field. return($items); } /** * Lookup the email of the state officer. Set email of notification to it. */ add_filter( 'gform_notification_1', 'set_receivers_email', 10, 3 ); function set_receivers_email ( $notification, $form, $entry ) { // Are we sending mail to state officer? if ($_POST['input_19'] == '0') { // Get the email of the state officer or chapter president. $result = getDbObject()->dbQuery( "SELECT email ". "FROM view_sar_get_all_officer_roster ". "WHERE officeAbbr = '".$_POST['input_10']."' OR ". " (chapAbbr = '".$_POST['input_10']."' AND officeAbbr = 'CPRES')" ); // Did we find an email? Add to notification. Add it to $entry. if (sizeof($result) == 1) { $notification['to'] = $result[0]['email']; GFAPI::update_entry_field($entry['id'],"24",$result[0]['email']); } } return($notification); } /** * Lookup the chaper and the email for the membership inquiry. Set email of notification to them. */ add_filter( 'gform_notification_2', 'set_member_referral_emals', 10, 3 ); function set_member_referral_emals( $notification, $form, $entry ) { // Get emails of state registrars and secretary. $result = getDbObject()->dbQuery( "SELECT GROUP_CONCAT(email SEPARATOR ';') as 'emails' FROM view_sar_get_all_officer_roster WHERE officeAbbr in ('SSEC','SREGG','SAREGG')" ); // Did we find the emails? Add emails to notification. Add fields to to $entry. if (sizeof($result) == 1) { $notification['to'] = $result[0]['emails']; GFAPI::update_entry_field($entry['id'],"17",$result[0]['emails']); } return($notification); } /** * Lookup the chaper and the email for the membership inquiry. Set email of notification to them. */ add_filter( 'gform_notification_10', 'set_inquiry_emails', 10, 3 ); function set_inquiry_emails ( $notification, $form, $entry ) { // Get emails of state/chapter registrars and chapter president. $result = getDbObject()->dbQuery( "SELECT a.chapter, GROUP_CONCAT(c.email SEPARATOR ',') as 'emails' ". "FROM wp_sar_zipCountyRef a, view_sar_get_all_officer_roster b, wp_sar_currentMembers c ". "WHERE ((a.chapter = b.chapAbbr AND b.officeAbbr in ('CPRES','CMBR')) OR b.officeAbbr = 'SREGG') AND ". " b.nationalNum = c.nationalNum AND ". " a.zip = '".substr($_POST['input_24_5'],0,5)."'" ); // Did we find the emails? Add emails to notification. Add fields to to $entry. if (sizeof($result) == 1) { $notification['to'] = $result[0]['emails']; GFAPI::update_entry_field($entry['id'],"19",$result[0]['chapter']); GFAPI::update_entry_field($entry['id'],"23",$result[0]['emails']); } return($notification); } /** * If creating a new membership record, take the next lowest temporary number available * and assign it to the national number field of the membership record. * */ add_action( 'gform_pre_submission_6', 'member_rec_pre_submission_handler' ); function member_rec_pre_submission_handler($form) { if ( $_POST['input_10'] == G_TEMP_MEMBERSHIPNUM) { // Get the next available temporary membership number. $result = getDbObject()->dbQuery( "SELECT MIN(nationalNum)-1 as 'newNum' FROM view_sar_get_membership_records WHERE nationalNum > '".G_TEMP_MEMBERSHIPNUM."'" ); // Add the number to the form. if (sizeof($result) == 1) $_POST['input_10'] = $result[0]['newNum']; } } /** * Forward user to membership maintance page after editing of member record. * (GravityForms "confirmation" is broken on form.) * */ add_action( 'gform_after_submission_6', 'update_membership_record', 10, 2 ); function update_membership_record( $entry, $form ) { wp_redirect("/maintain"); } /** * Dynamically initialize the drop downs with a list of members and the general * numbers and loads the dropdown with it. */ add_filter('gform_pre_render','populate_dropDowns'); add_filter('gform_admin_pre_render','populate_dropDowns'); function populate_dropDowns($form) { // Scan throught the fields and load them by type. foreach ($form['fields'] as &$field ) { if (strpos( $field->cssClass,'load_current_chapters') !== false) { // Get a list of current chapters by name. $result = buildDropdownList( "SELECT chapAbbr as 'value', chapName as 'text' ". "FROM wp_sar_chapterRef ". "ORDER BY chapName", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_venues') !== false) { // Get a list of locations for events. $result = buildDropdownList( "SELECT entry_id as 'value', name as 'text' ". "FROM view_sar_get_event_locations ". "ORDER BY name ", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_this_years_events') !== false) { // Get the list of current chapters. $result = buildDropdownList( "SELECT DISTINCT b.unitName as 'value', b.unitDesc as 'text' ". "FROM wp_sar_salesPayments a, wp_sar_salesOrders b ". "WHERE a.invoiceNum = b.invoiceNum AND YEAR(a.date) = '20".G_YEAR."' ". "ORDER BY b.unitDesc", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_membership_types') !== false) { // Get the list of current chapters. $result = buildDropdownList( "SELECT DISTINCT memberType as 'value', memberType as 'text' ". "FROM view_sar_get_membership_records ". "UNION ". "SELECT 'Statistics' as 'value', 'Statistics' as 'text'", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_everyone') !== false) { // Get the list of all members of any type. $result = buildDropdownList( "SELECT nationalNum as 'value', ".G_DB_NAME_LFMS." as 'text' ". "FROM view_sar_get_membership_records ". "ORDER BY last, first, middle, suffix", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_members') !== false) { // Get the list of active members. $result = buildDropdownList( "SELECT nationalNum as 'value', ".G_DB_NAME_LFMS." as 'text' ". // "FROM view_sar_get_membership_records ". "FROM wp_sar_currentMembers ". "WHERE memberType in (".G_CURRENT_MEMBER_TYPES.") ". "ORDER BY last, first, middle, suffix", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'award_agents') !== false) { // Get those who are allowed to grant awards. $result = buildDropdownList( "SELECT pk as 'value', agent as 'text' ". "FROM wp_sar_awardAgents ". "ORDER BY pk", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'awards_available') !== false) { // Get the list of awards available to grant. $result = buildDropdownList( "SELECT pk as 'value', award as 'text' ". "FROM wp_sar_awardsAvailable ". "ORDER BY pk", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'member_login_id') !== false) { // Get a list of all member from year one. $result = buildDropdownList( "SELECT a.id as 'value', CONCAT(".G_DB_NAME_LFMS.",' (',a.user_login,' - ',DATE_FORMAT(b.dob,'%m%d'),')') as 'text' ". "FROM wp_users a, view_sar_get_membership_records b ". "WHERE a.user_login = b.nationalNum AND a.user_login REGEXP '^[0-9]+$' ". "ORDER BY b.last, b.first, b.middle, b.suffix", "" ); $field->choices = $result; } else if (strpos( $field->cssClass,'load_venues') !== false) { // Get the venues where we hold events. $result = buildDropdownList( "SELECT entry_id as 'value', name 'text' ". "FROM view_sar_get_event_locations ". "ORDER BY name", "" ); $field->choices = $result; } } return($form); } /** * Use the two-letter state code rather than the full name of the state. */ add_filter( 'gform_us_states', 'us_states' ); function us_states( $states ) { $new_states = array(); foreach ( $states as $state ) { $new_states[ GF_Fields::get( 'address' )->get_us_state_code( $state ) ] = $state; } return $new_states; } ?> {"id":17422,"date":"2020-06-07T08:37:16","date_gmt":"2020-06-07T12:37:16","guid":{"rendered":"https:\/\/www.massar.org\/?p=17422"},"modified":"2024-02-05T19:54:30","modified_gmt":"2024-02-05T19:54:30","slug":"battle-road-no-place-for-old-men-maybe-not","status":"publish","type":"post","link":"https:\/\/massar.org\/battle-road-no-place-for-old-men-maybe-not\/","title":{"rendered":"Battle Road: No Place for Old Men. Maybe Not!"},"content":{"rendered":"

\nBy Brett Osborn
\nSAR Magazine
\nWinter 2019-2020
\nVol. 114, No. 3, pp. 24-25\n<\/p>\n

\n <\/p>\n

\nThe Jason Russell house today\n<\/p>\n<\/div>\n

While there are disagreements about the starting date of the Revolutionary War and the first battle, April 19, 1775, is recognized as the signature event for the conflict. Gen. Thomas Gage — under guidance he was given on April 14, 1775 (written Jan. 27, 1775) from the British Secretary of State William Legge, Earl of Dartmouth — he sent soldiers of the Crown Forces to disarm rebels and imprison leaders in Massachusetts.1<\/sup> They were met with armed resistance at Lexington and Concord on April 19. The initial Crown Forces Regulars, under Lt. Col. Francis Smith, sent on the raid came under constant fire from gathering local militia. A relief force from Boston under Brigadier Earl Hugh Percy’s First Brigade was sent to reinforce and extract Lt. Col. Smith’s raiding party.\n<\/p>\n

Menotomy, Mass., April 19, 1775<\/h4>\n

\nThe village of Menotomy, Mass. (now Arlington), was named for the Algonquin word for “swift running water.”2<\/sup>\n<\/p>\n

\n“Menotomy was just a wide place in the road, a little village strung along for about a mile from Foot of the Rocks to Spy Pond, but it was a crossroads where routes coming into Boston from the north and west intersected \u2026 All roads, as it turned out, led to Menotomy when the purpose was to intercept the Regulars.”3<\/sup>\n<\/p>\n

\nThe old men of Menotomy captured the Redcoat Regulars’ powder supply wagons and 18 soldiers (according to the citation on the local historical marker).4<\/sup>\n<\/p>\n

\nBrigadier Earl Percy’s First Brigade was sent by Gen. Gage to reinforce Lt. Col. Smith’s Force on a raid to Lexington and Concord. Behind his brigade followed two supply wagons with gunpowder and a 12-man guard trying to catch up with Percy’s force. In Menotomy, a group of men, too old to be fit for active service, gathered on the main road after Percy’s Brigade of regulars marched through. All were armed, and some were French and Indian War veterans. These included David Lamson, who was half-Indian and half-African; Ammi Cutter; Jason and Joseph Belknap; James Budge; and Israel Mead, who were seeking an opportunity to interdict stragglers from Percy’s column. Hiding behind a stone wall, they fired on the first wagon and killed the driver and a horse (other sources list two sergeants, more horses killed and an officer wounded.5<\/sup>). The guards surrendered. (Local lore says six regulars threw their muskets in a nearby pond and surrendered to an old woman in her garden.)\n<\/p>\n

\nThey then captured the second wagon. The powder was provided to passing militia, and the captured wagons, equipment, horses and Redcoat Regulars were moved. Later, a commandeered chaise with Redcoat Regular Lieutenant Edward Thoroton Gould — who was part of Lt. Col. Smith’s force and was wounded in the foot at Concord Bridge — was intercepted and captured by this same group of old men.\n<\/p>\n

\n\"\"“It is no wonder that Percy and Smith were astounded by the number of troops the province was able to muster at Menotomy only three hours after Percy passed through the empty town \u2026 There were as many minute men and militia waiting for him in Menotomy as there were to his rear and on the flanks.”6<\/sup>\n<\/p>\n

\n“The minute men and militia waiting in the town were operating under one great disadvantage: they had not seen the Regulars column, and they assumed that it would come down the main road in a tight formation, just as the Regulars had marched in all their earlier excursions out of Boston. The strong Regular flank patrols employed by Percy were a deadly surprise to many of the provincial companies that were situated too close to the road and were caught between the flankers and the main column. This mistake proved costly to several rebel units, including the minute men company from Danvers commanded by Lt. Gideon Foster.” They lost seven men at the Jason Russell house.7<\/sup>\n<\/p>\n

\nOn the south side of the road passing through Menotomy, 58-year old Jason Russell’s yellow-painted house was the scene of intense fighting as militia fought Redcoat Regulars. Russell, lame and barely able to walk, sent his family to safety and determined to defend hearth and home. Old Ammi Cutter, one of the group of exempts who had captured the wagons earlier in the day, lived across the street from Russell. Cutter, one of the few men there who had already fired his musket at the Regulars that day, was out on the road at this time, and he saw Russell come out of the house, musket in hand. Cutter thought his old friend was taking things a bit too far. He tried to tell Russell that the battlefield was no place for an old man, but Russell, who was piling bundles of shingles into a makeshift wall near his front door,8<\/sup> answered simply, “An Englishman’s home is his castle.”9<\/sup> Some militia and minutemen joined him. When Russell’s body was found, he had been shot twice and had 11 bayonet wounds. Eleven other Patriot militia and two Redcoat Regulars died in the Russell house, others in the yard. The struggle raged from the attic to the cellar in the house. It is now a museum and still has bullet holes in some of the rooms.\n<\/p>\n

\n

Battle Road \u2013 Menotomy Facts<\/p>\n

    \n
  • \nIn Menotomy, Redcoat Regulars had 40 killed in action and 80 wounded in action and about 19 captured, almost half of the Crown Forces casualties for Battle Road.\n<\/li>\n
  • \nThe Provincials casualties include 25 killed (including non-combatants), nine wounded in action, and one captured (Josiah Breed, Lynn, Mass., whom militiaman captured at Russell house).\n<\/li>\n
  • \nLt. Edward Gould of the 4th Regiment Light Company, wounded at Concord Bridge and captured by the elder men of Menotomy, was later exchanged for Militiaman Josiah Breed in May 1775.\n<\/li>\n
      \n<\/div>\n

      \nSamuel Whittemore served in the Queen Dragoons, in both the King George’s War and the French and Indian War. Born in England in 1695, he fought native warriors in the Indian Wars of 1763. He then settled in the Massachusetts Colony. As the fighting started in Lexington and Concord in 1775, he watched Crown Forces retreating toward Menotomy from his home. He took all his weapons, a brace of pistols, an old cavalry saber, a musket and a powder horn and “told his wife he was going up town to meet the regulars.”10<\/sup> He engaged Redcoat Regulars of Col. Nesbitt’s 47th Regiment. He shot three at point-blank range, drew his saber and started slashing at the approaching bayonets. Whittemore was shot in the face, was butt-stroked and received multiple bayonet wounds before being left for dead. When townspeople went to collect his body, they found Whittemore reloading his musket to continue the fight. He was taken to a local tavern, where doctors believed his 14 wounds were mortal and sent him home to his family to die. Samuel Whittemore lived to the age of 98 and passed in February 1793, the oldest Revolutionary War combatant. His marker is in Arlington, Mass.\n<\/p>\n

      \n“The repeated bayonetting of Russell and Whittemore is one indication of the fierceness that characterized the fighting at that point. To the Regulars, the rebels were cowardly snipers who fired from hiding and who lurked along the edges of the column like wolves, ready to kill and scalp wounded men who had to be left behind; while to the militia and Minutemen, the Regulars were brutal ravagers who burned and looted their way across the countryside.”11<\/sup>\n<\/p>\n

      \nEach village along Battle Road has legends and stories about local Patriots who on that significant day of April 19, 1775, rose to the occasion. Those who were exempted from active military service because of age or infirmity or who were not white males, were among those who stepped forward. May their sacrifices and valor be forever remembered.\n<\/p>\n