private function create_swpm_user() { global $wpdb; $member = SwpmTransfer::$default_fields; $form = new SwpmFrontForm($member); if (!$form->is_valid()) { $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following'), 'extra' => $form->get_errors()); SwpmTransfer::get_instance()->set('status', $message); return false; } $member_info = $form->get_sanitized(); $free_level = SwpmUtils::get_free_level(); $account_status = SwpmSettings::get_instance()->get_value('default-account-status', 'active'); $member_info['last_accessed_from_ip'] = SwpmUtils::get_user_ip_address(); $member_info['member_since'] = date("Y-m-d"); $member_info['subscription_starts'] = date("Y-m-d"); $member_info['account_state'] = $account_status; $plain_password = $member_info['plain_password']; unset($member_info['plain_password']); if (SwpmUtils::is_paid_registration()) { $member_info['reg_code'] = ''; $member_id = filter_input(INPUT_GET, 'member_id', FILTER_SANITIZE_NUMBER_INT); $code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING); $wpdb->update($wpdb->prefix . "swpm_members_tbl", $member_info, array('member_id' => $member_id, 'reg_code' => $code)); $query = $wpdb->prepare('SELECT membership_level FROM ' . $wpdb->prefix . 'swpm_members_tbl WHERE member_id=%d', $member_id); $member_info['membership_level'] = $wpdb->get_var($query); $last_insert_id = $member_id; } else { if (!empty($free_level)) { $member_info['membership_level'] = $free_level; $wpdb->insert($wpdb->prefix . "swpm_members_tbl", $member_info); $last_insert_id = $wpdb->insert_id; } else { $message = array('succeeded' => false, 'message' => SwpmUtils::_('Membership Level Couldn\'t be found.')); SwpmTransfer::get_instance()->set('status', $message); return false; } } $member_info['plain_password'] = $plain_password; $this->member_info = $member_info; return true; }