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; } ?> {"version":"1.0","provider_name":"MASSAR","provider_url":"https:\/\/massar.org","author_name":"admin","author_url":"https:\/\/massar.org\/author\/166690\/","title":"Golden State Hosts Congress in Orange County","type":"rich","width":600,"height":338,"html":"
Golden State Hosts Congress in Orange County<\/a><\/blockquote>