public function saveContactBillingData( $ref_dest )
{
$required_fields = $errors = array();
- $city_name = '';
- $billingAccount = new GlmDataAccounts( $this->wpdb, $this->config );
- $billingFields = $billingAccount->fields;
+ $city_name = '';
+ $billingAccount = new GlmDataAccounts( $this->wpdb, $this->config );
+ $billingFields = $billingAccount->fields;
if ( $billingFields ) {
foreach( $billingFields as $field_name => $field ) {
if ( $field['required'] ) {
$billing_updated_format,
array( '%d' )
);
+ } else {
+ // Get the member name
+ $member_name = $this->wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $member_id" );
+ // Need to create an account record
+ $billing_updated['ref_name'] = $member_name; // Use members name
+ $billing_updated['ref_dest'] = $member_id;
+ $billing_updated['anniversary_date'] = date('Y-m-d H:i:s');
+ $billing_updated_format[] = '%s';
+ $billing_updated_format[] = '%d';
+ $billing_updated_format[] = '%s';
+ $this->wpdb->insert(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
+ $billing_updated,
+ $billing_updated_format
+ );
}
} else {
return $errors;