From: Steve Sutton Date: Mon, 8 Apr 2019 13:13:20 +0000 (-0400) Subject: Update to check for member name match X-Git-Tag: v1.0.26^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d60e48eb93381e58e13c390f7af4f80562cfb780;p=WP-Plugins%2Fglm-member-db-billing.git Update to check for member name match If the member name already exists then give a error message. --- diff --git a/index.php b/index.php index 71a72d4..35ececd 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Billing * Plugin URI: http://www.gaslightmedia.com/ * Description: This is glmAssociate Billing Module - * Version: 1.0.25 + * Version: 1.0.26 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersBillingAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.25 + * @version 1.0.26 */ /* @@ -37,7 +37,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.25'); +define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.26'); define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.26'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/front/billing/becomeMember.php b/models/front/billing/becomeMember.php index 5c6eba7..89e59e7 100644 --- a/models/front/billing/becomeMember.php +++ b/models/front/billing/becomeMember.php @@ -173,6 +173,21 @@ class GlmMembersFront_billing_becomeMember // extends GlmDataBilling $member_fname = filter_var( $_REQUEST['fname'], FILTER_SANITIZE_STRING ); $member_lname = filter_var( $_REQUEST['lname'], FILTER_SANITIZE_STRING ); $member_name = $member_lname . ', ' . $member_fname; + // Check member name. If it matches then give error member already exists + $memberAlreadyExist = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + WHERE member_name = %s", + $member_name + ) + ); + // echo '
$memberAlreadyExist: ' . print_r( $memberAlreadyExist, true ) . '
'; + if ( $memberAlreadyExist ) { + $error = true; + $messages[] = $errors['member_name'] = "There's a Member with that Name already!"; + } + $invoice_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ); // Member type is based on the renewing_member field (invoice_types) $invoice_type_data = $BillingSupport->getInvoiceTypeById( $invoice_type ); @@ -186,365 +201,367 @@ class GlmMembersFront_billing_becomeMember // extends GlmDataBilling $error = true; $messages[] = 'An error occurred! member_type'; } - // echo '
$member_type: ' . print_r( $member_type, true ) . '
'; - // Start database transaction - $this->wpdb->show_errors(); - $this->wpdb->query('START TRANSACTION'); - // $access = $this->config['access_numb']['Full']; - $this->wpdb->insert( - GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', - array( - 'access' => 40, // Not Moderated - 'member_type' => $member_type, - 'created' => date( 'Y-m-d' ), - 'name' => $member_name, - 'member_slug' => sanitize_title( $member_name ), - ), - array( - '%d',// access - '%d',// member_type - '%s',// created - '%s',// name - '%s',// member_slug - ) - ); - $member_id = $this->wpdb->insert_id; - // echo '
$member_id: ' . print_r( $member_id, true ) . '
'; - if ( !$member_id ) { - $error = true; - $messages[] = 'An error occurred! member_id'; - } else { - $member = $this->wpdb->get_row( - $this->wpdb->prepare( - "SELECT * - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE id = %d", - $member_id + if ( !$error ) { // first error check + // echo '
$member_type: ' . print_r( $member_type, true ) . '
'; + // Start database transaction + $this->wpdb->show_errors(); + $this->wpdb->query('START TRANSACTION'); + // $access = $this->config['access_numb']['Full']; + $this->wpdb->insert( + GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + array( + 'access' => 40, // Not Moderated + 'member_type' => $member_type, + 'created' => date( 'Y-m-d' ), + 'name' => $member_name, + 'member_slug' => sanitize_title( $member_name ), + ), + array( + '%d',// access + '%d',// member_type + '%s',// created + '%s',// name + '%s',// member_slug ) ); - // echo '
$member: ' . print_r( $member, true ) . '
'; - } - // 2. Setup the member_info - $billing_addr1 = filter_var( $_REQUEST['billing_addr1'] ); - $billing_city = filter_var( $_REQUEST['billing_city'] ); - $billing_city_id = $this->getCityId( $billing_city ); - // echo '
$billing_city_id: ' . print_r( $billing_city_id, true ) . '
'; - $billing_state = filter_var( $_REQUEST['billing_state'] ); - $billing_zip = filter_var( $_REQUEST['billing_zip'] ); - $phone = filter_var( $_REQUEST['phone'] ); - $website = filter_var( $_REQUEST['website'] ); - $email_on_website = filter_var( $_REQUEST['email_on_website'] ); - - $this->wpdb->insert( - GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', - array( - 'member' => $member_id, - 'member_name' => $member_name, - 'status' => 10, - 'reference_name' => 'new member form', - 'addr1' => $billing_addr1, - 'city' => $billing_city_id, - 'state' => $billing_state, - 'zip' => $billing_zip, - 'phone' => $phone, - 'url' => $website, - 'email' => $email_on_website, - 'create_time' => date( 'Y-m-d' ), - ), - array( - '%d', // member - '%s', // member_name - '%d', // status - '%s', // reference_name - '%s', // addr1 - '%d', // city - '%s', // state - '%s', // zip - '%s', // phone - '%s', // url - '%s', // email - '%s', // create_time - ) - ); - $member_info_id = $this->wpdb->insert_id; - if ( !$member_info_id ) { - $error = true; - $messages[] = 'An error occurred! member_info_id'; - } else { - $member_info = $this->wpdb->get_row( - $this->wpdb->prepare( - "SELECT * - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info - WHERE id = %d", - $member_info_id + $member_id = $this->wpdb->insert_id; + // echo '
$member_id: ' . print_r( $member_id, true ) . '
'; + if ( !$member_id ) { + $error = true; + $messages[] = 'An error occurred! member_id'; + } else { + $member = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT * + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE id = %d", + $member_id + ) + ); + // echo '
$member: ' . print_r( $member, true ) . '
'; + } + // 2. Setup the member_info + $billing_addr1 = filter_var( $_REQUEST['billing_addr1'] ); + $billing_city = filter_var( $_REQUEST['billing_city'] ); + $billing_city_id = $this->getCityId( $billing_city ); + // echo '
$billing_city_id: ' . print_r( $billing_city_id, true ) . '
'; + $billing_state = filter_var( $_REQUEST['billing_state'] ); + $billing_zip = filter_var( $_REQUEST['billing_zip'] ); + $phone = filter_var( $_REQUEST['phone'] ); + $website = filter_var( $_REQUEST['website'] ); + $email_on_website = filter_var( $_REQUEST['email_on_website'] ); + + $this->wpdb->insert( + GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info', + array( + 'member' => $member_id, + 'member_name' => $member_name, + 'status' => 10, + 'reference_name' => 'new member form', + 'addr1' => $billing_addr1, + 'city' => $billing_city_id, + 'state' => $billing_state, + 'zip' => $billing_zip, + 'phone' => $phone, + 'url' => $website, + 'email' => $email_on_website, + 'create_time' => date( 'Y-m-d' ), + ), + array( + '%d', // member + '%s', // member_name + '%d', // status + '%s', // reference_name + '%s', // addr1 + '%d', // city + '%s', // state + '%s', // zip + '%s', // phone + '%s', // url + '%s', // email + '%s', // create_time ) ); - // echo '
$member_info: ' . print_r( $member_info, true ) . '
'; - } - // 3. Setup the contact (and wpUser) - // Determine the Worpress Role to be used for contact import - Using Entity Manager right now - $contactRoleNumb = $this->config['contact_role_numb']['LogInContact']; - $wpRole = $this->config['contact_role_wordpress'][$contactRoleNumb]; - $memberContactEmail = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ); - $memberLogin = filter_var( $_REQUEST['username'] ); - $org = filter_var( $_REQUEST['org'] ); - $title = filter_var( $_REQUEST['title'] ); - $this->wpdb->insert( - GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', - array( - 'active' => true, - 'primary_contact' => true, - 'access' => $this->config['access_numb']['Full'], - 'fname' => $member_fname, - 'lname' => $member_lname, - 'contact_type' => $this->config['contact_type_numb']['Personal'], - 'contact_role' => $contactRoleNumb, - 'email' => $memberContactEmail, - 'username' => $memberLogin, - 'notes' => 'Become Member Form.', - 'create_time' => date('Y-m-d H:i:s', time()), - 'ref_type' => $this->config['ref_type_numb']['Member'], - 'ref_dest' => $member_id, - 'org' => $org, - 'title' => $title, - 'business_fname' => $member_fname, - 'business_lname' => $member_lname, - 'business_addr1' => $billing_addr1, - 'business_city' => $billing_city_id, - 'business_state' => $billing_state, - 'business_zip' => $billing_zip, - 'business_publish' => 1 - ), - array( - '%d', // active - '%d', // primary_contact - '%d', // access - '%s', // fname - '%s', // lname - '%d', // contact_type - '%d', // contact_role - '%s', // email - '%s', // username - '%s', // notes - '%s', // create_time - '%d', // ref_type - '%d', // ref_dest - '%s', // org - '%s', // title - '%s', // business_fname - '%s', // business_lname - '%s', // business_addr1 - '%s', // business_city - '%s', // business_state - '%s', // business_zip - '%s', // business_publish - ) - ); - $newContactID = $this->wpdb->insert_id; - if ( $newContactID ) { - $new_contact = $this->wpdb->get_row( - $this->wpdb->prepare( - "SELECT * - FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts - WHERE id = %d", - $newContactID + $member_info_id = $this->wpdb->insert_id; + if ( !$member_info_id ) { + $error = true; + $messages[] = 'An error occurred! member_info_id'; + } else { + $member_info = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT * + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + WHERE id = %d", + $member_info_id + ) + ); + // echo '
$member_info: ' . print_r( $member_info, true ) . '
'; + } + // 3. Setup the contact (and wpUser) + // Determine the Worpress Role to be used for contact import - Using Entity Manager right now + $contactRoleNumb = $this->config['contact_role_numb']['LogInContact']; + $wpRole = $this->config['contact_role_wordpress'][$contactRoleNumb]; + $memberContactEmail = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ); + $memberLogin = filter_var( $_REQUEST['username'] ); + $org = filter_var( $_REQUEST['org'] ); + $title = filter_var( $_REQUEST['title'] ); + $this->wpdb->insert( + GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', + array( + 'active' => true, + 'primary_contact' => true, + 'access' => $this->config['access_numb']['Full'], + 'fname' => $member_fname, + 'lname' => $member_lname, + 'contact_type' => $this->config['contact_type_numb']['Personal'], + 'contact_role' => $contactRoleNumb, + 'email' => $memberContactEmail, + 'username' => $memberLogin, + 'notes' => 'Become Member Form.', + 'create_time' => date('Y-m-d H:i:s', time()), + 'ref_type' => $this->config['ref_type_numb']['Member'], + 'ref_dest' => $member_id, + 'org' => $org, + 'title' => $title, + 'business_fname' => $member_fname, + 'business_lname' => $member_lname, + 'business_addr1' => $billing_addr1, + 'business_city' => $billing_city_id, + 'business_state' => $billing_state, + 'business_zip' => $billing_zip, + 'business_publish' => 1 + ), + array( + '%d', // active + '%d', // primary_contact + '%d', // access + '%s', // fname + '%s', // lname + '%d', // contact_type + '%d', // contact_role + '%s', // email + '%s', // username + '%s', // notes + '%s', // create_time + '%d', // ref_type + '%d', // ref_dest + '%s', // org + '%s', // title + '%s', // business_fname + '%s', // business_lname + '%s', // business_addr1 + '%s', // business_city + '%s', // business_state + '%s', // business_zip + '%s', // business_publish + ) + ); + $newContactID = $this->wpdb->insert_id; + if ( $newContactID ) { + $new_contact = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT * + FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts + WHERE id = %d", + $newContactID + ) + ); + // echo '
$new_contact: ' . print_r( $new_contact, true ) . '
'; + } else { + // $this->wpdb->print_error(); + $error = true; + $messages[] = 'An error occurred! newContactID'; + } + $memberPasswd = filter_var( $_REQUEST['password'] ); + $wpUserID = wp_insert_user( + array( + 'user_email' => $memberContactEmail, + 'user_login' => $memberLogin, + 'user_pass' => $memberPasswd, + 'first_name' => $member_fname, + 'last_name' => $member_lname, + 'role' => $wpRole ) ); - // echo '
$new_contact: ' . print_r( $new_contact, true ) . '
'; - } else { - // $this->wpdb->print_error(); - $error = true; - $messages[] = 'An error occurred! newContactID'; - } - $memberPasswd = filter_var( $_REQUEST['password'] ); - $wpUserID = wp_insert_user( - array( - 'user_email' => $memberContactEmail, - 'user_login' => $memberLogin, - 'user_pass' => $memberPasswd, - 'first_name' => $member_fname, - 'last_name' => $member_lname, - 'role' => $wpRole - ) - ); - // echo '
$wpUserID: ' . print_r( $wpUserID, true ) . '
'; - if (is_int($wpUserID) && $wpUserID > 0) { - // Store the contact ID and active status into user meta data. - update_user_meta($wpUserID, 'glmMembersContactID', $newContactID); - update_user_meta($wpUserID, 'glmMembersContactActive', true); // echo '
$wpUserID: ' . print_r( $wpUserID, true ) . '
'; - } else if ( is_wp_error( $wpUserID ) ) { - $error = true; - $messages[''] = $errors['username'] = 'An error occurred! ' . $wpUserID->get_error_message() . ''; - } else { - $error = true; - $messages[] = 'An error occurred! wpUserID'; - } - // 4. Setup the custom fields - // Process any custom fields - if ( isset( $_REQUEST['cf'] ) && !empty( $_REQUEST['cf'] ) ) { - foreach ( $_REQUEST['cf'] as $customFieldKey => $customFieldValue ) { - $customFieldKey = filter_var( $customFieldKey, FILTER_VALIDATE_INT ); - $customFieldValue = filter_var( $customFieldValue ); - if ( $customFieldKey && $customFieldValue ) { - if ( in_array( $customFieldKey, array( 2, 3 ) ) ) { - $customFieldValue = 'Yes'; - } - $this->wpdb->insert( - GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . 'custom_field_data', - array( - 'entity_id' => $newContactID, - 'field_id' => $customFieldKey, - 'field_data' => $customFieldValue - ), - array( - '%d', - '%d', - '%s' - ) - ); - $customFieldId = $this->wpdb->insert_id; - if ( $customFieldId ) { - // echo '
$customFieldId: ' . print_r( $customFieldId, true ) . '
'; - } else { - $error = true; - $messages[] = 'An error occurred! customFieldId'; + if (is_int($wpUserID) && $wpUserID > 0) { + // Store the contact ID and active status into user meta data. + update_user_meta($wpUserID, 'glmMembersContactID', $newContactID); + update_user_meta($wpUserID, 'glmMembersContactActive', true); + // echo '
$wpUserID: ' . print_r( $wpUserID, true ) . '
'; + } else if ( is_wp_error( $wpUserID ) ) { + $error = true; + $messages[''] = $errors['username'] = 'An error occurred! ' . $wpUserID->get_error_message() . ''; + } else { + $error = true; + $messages[] = 'An error occurred! wpUserID'; + } + // 4. Setup the custom fields + // Process any custom fields + if ( isset( $_REQUEST['cf'] ) && !empty( $_REQUEST['cf'] ) ) { + foreach ( $_REQUEST['cf'] as $customFieldKey => $customFieldValue ) { + $customFieldKey = filter_var( $customFieldKey, FILTER_VALIDATE_INT ); + $customFieldValue = filter_var( $customFieldValue ); + if ( $customFieldKey && $customFieldValue ) { + if ( in_array( $customFieldKey, array( 2, 3 ) ) ) { + $customFieldValue = 'Yes'; + } + $this->wpdb->insert( + GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . 'custom_field_data', + array( + 'entity_id' => $newContactID, + 'field_id' => $customFieldKey, + 'field_data' => $customFieldValue + ), + array( + '%d', + '%d', + '%s' + ) + ); + $customFieldId = $this->wpdb->insert_id; + if ( $customFieldId ) { + // echo '
$customFieldId: ' . print_r( $customFieldId, true ) . '
'; + } else { + $error = true; + $messages[] = 'An error occurred! customFieldId'; + } } } } - } - // Setup billing account - $this->wpdb->insert( - GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts', - array( - 'ref_dest' => $member_id, - 'ref_name' => $member_name, - 'anniversary_date' => date( 'Y-m-d' ), - 'boss' => false, - 'invoice_type' => $invoice_type, - 'billing_fname' => $member_fname, - 'billing_lname' => $member_lname, - 'billing_addr1' => $billing_addr1, - 'billing_city' => $billing_city, - 'billing_state' => $billing_state, - 'billing_zip' => $billing_zip, - 'billing_phone' => $billing_phone, - 'email' => $memberContactEmail, - ), - array( - '%d', // ref_dest - '%s', // ref_name - '%s', // anniversary_date - '%d', // boss - '%d', // invoice_type - '%s', // billing_fname - '%s', // billing_lname - '%s', // billing_addr1 - '%s', // billing_city - '%s', // billing_state - '%s', // billing_zip - '%s', // billing_phone - '%s', // email - ) - ); - $accountID = $this->wpdb->insert_id; - if ( !$accountID ) { - $error = true; - $messages[] = 'An error occurred! accountID'; - } - // Save or rollback - if ( $error ) { - } else { - // $this->wpdb->query('ROLLBACK'); - - // Fetch the invoice type chosen by the member. - $member_invoice = $BillingSupport->getInvoiceTypeById( $invoice_type ); - // Here we'll create the invoice for the member. - $invoice_data = array( - 'account_id' => $accountID, - 'renew_type_id' => $invoice_type, - 'amount' => $_REQUEST['total_renew_amount'], - 'due_date' => date( 'Y-m-d' ), - 'member_invoice' => $member_invoice, - 'employee_data' => array(), - 'employees' => array(), + // Setup billing account + $this->wpdb->insert( + GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts', + array( + 'ref_dest' => $member_id, + 'ref_name' => $member_name, + 'anniversary_date' => date( 'Y-m-d' ), + 'boss' => false, + 'invoice_type' => $invoice_type, + 'billing_fname' => $member_fname, + 'billing_lname' => $member_lname, + 'billing_addr1' => $billing_addr1, + 'billing_city' => $billing_city, + 'billing_state' => $billing_state, + 'billing_zip' => $billing_zip, + 'billing_phone' => $billing_phone, + 'email' => $memberContactEmail, + ), + array( + '%d', // ref_dest + '%s', // ref_name + '%s', // anniversary_date + '%d', // boss + '%d', // invoice_type + '%s', // billing_fname + '%s', // billing_lname + '%s', // billing_addr1 + '%s', // billing_city + '%s', // billing_state + '%s', // billing_zip + '%s', // billing_phone + '%s', // email + ) ); - $invoice_id = $BillingSupport->createMemberInvoiceWithEmployees( $invoice_data ); - if ( !$invoice_id ) { - $this->wpdb->print_error(); + $accountID = $this->wpdb->insert_id; + if ( !$accountID ) { $error = true; - $messages[] = 'An error occurred! invoice_id'; + $messages[] = 'An error occurred! accountID'; } - if ( !$error ) { - - // Get payment type and process. - $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING ); - switch ( $payment_option ) { - case 'pay_by_credit_card': - // Setup $_REQUEST ARRAY for billing - $_REQUEST['billing_fname'] = $member_fname; - $_REQUEST['billing_lname'] = $member_lname; - $_REQUEST['billing_addr1'] = $billing_addr1; - $_REQUEST['billing_city'] = $billing_city; - $_REQUEST['billing_state'] = $billing_state; - $_REQUEST['billing_zip'] = $billing_zip; - $_REQUEST['billing_phone'] = $billing_phone; - $_REQUEST['email'] = $memberContactEmail; - // Do the Payment Processing. - $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); - if ( $processErrors ) { - // if ( count( $processErrors ) > 0 ) { - // $error = true; - // $error_message = ( isset( $processErrors[0] ) && $processErrors[0] ) ? $processErrors[0] : 'There was an error trying to process your card!'; - // $messages[] = 'An error occurred! ' . $error_message . ''; - // } - if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) { - $error = true; - foreach ( $processErrors as $error ) { - $messages[] = ''.$error.''; + // Save or rollback + if ( $error ) { + } else { + // $this->wpdb->query('ROLLBACK'); + + // Fetch the invoice type chosen by the member. + $member_invoice = $BillingSupport->getInvoiceTypeById( $invoice_type ); + // Here we'll create the invoice for the member. + $invoice_data = array( + 'account_id' => $accountID, + 'renew_type_id' => $invoice_type, + 'amount' => $_REQUEST['total_renew_amount'], + 'due_date' => date( 'Y-m-d' ), + 'member_invoice' => $member_invoice, + 'employee_data' => array(), + 'employees' => array(), + ); + $invoice_id = $BillingSupport->createMemberInvoiceWithEmployees( $invoice_data ); + if ( !$invoice_id ) { + $this->wpdb->print_error(); + $error = true; + $messages[] = 'An error occurred! invoice_id'; + } + if ( !$error ) { + + // Get payment type and process. + $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING ); + switch ( $payment_option ) { + case 'pay_by_credit_card': + // Setup $_REQUEST ARRAY for billing + $_REQUEST['billing_fname'] = $member_fname; + $_REQUEST['billing_lname'] = $member_lname; + $_REQUEST['billing_addr1'] = $billing_addr1; + $_REQUEST['billing_city'] = $billing_city; + $_REQUEST['billing_state'] = $billing_state; + $_REQUEST['billing_zip'] = $billing_zip; + $_REQUEST['billing_phone'] = $billing_phone; + $_REQUEST['email'] = $memberContactEmail; + // Do the Payment Processing. + $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); + if ( $processErrors ) { + // if ( count( $processErrors ) > 0 ) { + // $error = true; + // $error_message = ( isset( $processErrors[0] ) && $processErrors[0] ) ? $processErrors[0] : 'There was an error trying to process your card!'; + // $messages[] = 'An error occurred! ' . $error_message . ''; + // } + if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) { + $error = true; + foreach ( $processErrors as $error ) { + $messages[] = ''.$error.''; + } + } else if ( isset( $processErrors ) && $processErrors ) { + $error = true; + $messages[] = ''.$processErrors.''; } - } else if ( isset( $processErrors ) && $processErrors ) { - $error = true; - $messages[] = ''.$processErrors.''; } + + break; + case 'pay_by_check': + break; } - break; - case 'pay_by_check': - break; } - } - - if ( $error ) { - $this->wpdb->query('ROLLBACK'); - } else { - $this->wpdb->query('COMMIT'); - $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); - $view = 'thankyou'; - // Send admin user email notification of new member - - // Check for any notices for new members and send them out for this new member. - $Notification = new GlmNotifications( $this->wpdb, $this->config ); - - // Get all new member notifications for the member and if found send them out. - $newMemberNotices = $Notification->getNotificationsByType( 'New Member' ); - if ( $newMemberNotices ) { - foreach ( $newMemberNotices as $notification ) { - $Notification->sendEmailNotification( $notification['id'], $accountID ); + if ( $error ) { + $this->wpdb->query('ROLLBACK'); + } else { + $this->wpdb->query('COMMIT'); + $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); + $view = 'thankyou'; + // Send admin user email notification of new member + + // Check for any notices for new members and send them out for this new member. + $Notification = new GlmNotifications( $this->wpdb, $this->config ); + + // Get all new member notifications for the member and if found send them out. + $newMemberNotices = $Notification->getNotificationsByType( 'New Member' ); + if ( $newMemberNotices ) { + foreach ( $newMemberNotices as $notification ) { + $Notification->sendEmailNotification( $notification['id'], $accountID ); + } } - } - // Get all new member admin notifications for the member and if found send them out. - $adminNewMemberNotices = $Notification->getNotificationsByType( 'New Member Admin Notice' ); - if ( $adminNewMemberNotices ) { - foreach ( $adminNewMemberNotices as $notification ) { - $Notification->sendEmailNotification( $notification['id'], $accountID ); + // Get all new member admin notifications for the member and if found send them out. + $adminNewMemberNotices = $Notification->getNotificationsByType( 'New Member Admin Notice' ); + if ( $adminNewMemberNotices ) { + foreach ( $adminNewMemberNotices as $notification ) { + $Notification->sendEmailNotification( $notification['id'], $accountID ); + } } - } + } } - } + } // End of first error check break; default: diff --git a/views/front/billing/becomeMember.html b/views/front/billing/becomeMember.html index 6d99adf..53bdd25 100644 --- a/views/front/billing/becomeMember.html +++ b/views/front/billing/becomeMember.html @@ -69,6 +69,7 @@ required /> + {if isset($errors.member_name) && $errors.member_name}
{$errors.member_name}
{/if}
Email