PluginProbe ʕ •ᴥ•ʔ
Event Tickets with Ticket Scanner / 2.7.0
Event Tickets with Ticket Scanner v2.7.0
3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.4 trunk 2.6.0 2.7.0 2.7.1 2.7.10 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3
event-tickets-with-ticket-scanner / sasoEventtickets_Frontend.php
event-tickets-with-ticket-scanner Last commit date
2.7.0 1 year ago 3rd 1 year ago css 1 year ago img 1 year ago languages 1 year ago ticket 1 year ago vendors 1 year ago SASO_EVENTTICKETS.php 1 year ago backend.js 1 year ago changelog.txt 1 year ago db.php 1 year ago index.php 1 year ago init_file.php 1 year ago js_seatingplan.js 1 year ago order_details.js 1 year ago readme.txt 1 year ago saso-eventtickets-validator.js 1 year ago sasoEventtickets_AdminSettings.php 1 year ago sasoEventtickets_Authtoken.php 1 year ago sasoEventtickets_Base.php 1 year ago sasoEventtickets_Core.php 1 year ago sasoEventtickets_Frontend.php 1 year ago sasoEventtickets_Messenger.php 1 year ago sasoEventtickets_Options.php 1 year ago sasoEventtickets_PDF.php 1 year ago sasoEventtickets_Ticket.php 1 year ago sasoEventtickets_TicketBadge.php 1 year ago sasoEventtickets_TicketDesigner.php 1 year ago sasoEventtickets_TicketQR.php 1 year ago ticket_events.js 1 year ago ticket_scanner.js 1 year ago validator.js 1 year ago wc_backend.js 1 year ago wc_frontend.js 1 year ago woocommerce-hooks.php 1 year ago
sasoEventtickets_Frontend.php
423 lines
1 <?php
2 include_once(plugin_dir_path(__FILE__)."init_file.php");
3 class sasoEventtickets_Frontend {
4 private $MAIN;
5
6 public function __construct($MAIN) {
7 $this->MAIN = $MAIN;
8 }
9
10 private function getDB() {
11 return $this->MAIN->getDB();
12 }
13 private function getBase() {
14 return $this->MAIN->getBase();
15 }
16 private function getCore() {
17 return $this->MAIN->getCore();
18 }
19
20 public function executeJSON($a, $data=[]) {
21 $ret = "";
22 $justJSON = false;
23 try {
24 switch (trim($a)) {
25 case "checkCode":
26 $ret = $this->checkCode($data);
27 break;
28 case "getOptions":
29 $ret = $this->getOptions();
30 break;
31 case "registerToCode":
32 $ret = $this->registerToCode($data);
33 break;
34 case "premium":
35 $ret = $this->executeJSONPremium($data);
36 break;
37 default:
38 throw new Exception(sprintf(esc_html__('function "%s" not implemented', 'event-tickets-with-ticket-scanner')));
39 }
40 } catch(Exception $e) {
41 //$this->MAIN->getAdmin()->logErrorToDB($e);
42 return wp_send_json_error (['msg'=>$e->getMessage()]);
43 }
44 if ($justJSON) return wp_send_json($ret);
45 else return wp_send_json_success( $ret );
46 }
47
48 private function executeJSONPremium($data) {
49 if (!$this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'executeFrontendJSON')) throw new Exception("#9001a premium is not active");
50 if (!isset($data['d'])) throw new Exception("#9002a premium action is missing");
51 return $this->MAIN->getPremiumFunctions()->executeFrontendJSON($data['d'], $data);
52 }
53
54 private function checkIfOnlyLoggedInIsAffected($data) {
55 if ($this->MAIN->getOptions()->isOptionCheckboxActive('onlyForLoggedInWPuser') && !is_user_logged_in()) {
56 $v = trim($this->MAIN->getOptions()->getOptionValue('onlyForLoggedInWPuserMessage'));
57 throw new Exception($v);
58 }
59 return $data;
60 }
61
62 public function isUsed($codeObj) {
63 $ret = false;
64 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
65 if (!empty($metaObj['used']['reg_request'])) {
66 $ret = true;
67 }
68 $ret = apply_filters( $this->MAIN->_add_filter_prefix.'frontend_isUsed', $ret );
69 return $ret;
70 }
71 public function markAsUsed($codeObj, $force=false) {
72 if ($force || $this->MAIN->getOptions()->isOptionCheckboxActive('oneTimeUseOfRegisterCode')) {
73 if ($codeObj['aktiv'] == 1) {
74 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
75 // check ob nicht schon used
76 if (!empty($metaObj['used']['reg_request'])) {
77 $codeObj['_valid'] = 5; // used
78 } else {
79 $confirmedCount = isset($metaObj['confirmedCount']) ? intval($metaObj['confirmedCount']) : 0;
80 $confirmedCount++; // da erst am ende der Count erhöht wird, hier schon +1 machen
81 if ($force) {
82 $optionCount = 1;
83 } else {
84 // setze als used
85 $optionCount = intval($this->MAIN->getOptions()->getOptionValue('oneTimeUseOfRegisterAmount'));
86 if ($optionCount < 1) $optionCount = 1;
87 // check if code has list
88 if ($codeObj['list_id'] > 0) {
89 // lade liste , um auf code list ebene einen abweichenden Wert zu prüfen
90 $listObj = $this->getCore()->getListById($codeObj['list_id']);
91 $listObjMeta = [];
92 // check if code has in metaObj a value set and if it is > 0
93 if (isset($listObj["meta"]) && $listObj["meta"] != "") {
94 $listObjMeta = array_replace_recursive($listObjMeta, json_decode($listObj['meta'], true));
95 if (isset($listObjMeta['oneTimeUseOfRegisterAmount'])) {
96 $_optionCount = intval($listObjMeta['oneTimeUseOfRegisterAmount']);
97 if ($_optionCount > 0) $optionCount = $_optionCount;
98 }
99 }
100 }
101 }
102 if ($optionCount <= $confirmedCount) {
103 $metaObj = $this->addNewUsedEntryToMetaObject($metaObj);
104 $codeObj['meta'] = $this->getCore()->json_encode_with_error_handling($metaObj);
105 $this->getDB()->update("codes", ["meta"=>$codeObj['meta']], ['id'=>$codeObj['id']]);
106 $this->getCore()->triggerWebhooks(6, $codeObj);
107 }
108 }
109 }
110 }
111 do_action( $this->MAIN->_do_action_prefix.'frontend_markAsUsed', $codeObj );
112 return $codeObj;
113 }
114
115 private function checkTicket($codeObj) {
116 if ($codeObj != null && isset($codeObj['order_id']) && $codeObj['order_id'] > 0) {
117 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
118 if (isset($metaObj['woocommerce'])
119 && $metaObj['woocommerce']['order_id'] > 0
120 && isset($metaObj['wc_ticket'])
121 && $metaObj['wc_ticket']['is_ticket'] == 1) {
122 if ($metaObj['wc_ticket']['redeemed_date'] != "") {
123 $codeObj['_valid'] = 8; // ticket redeemed
124 }
125 }
126 }
127 $codeObj = apply_filters( $this->MAIN->_add_filter_prefix.'frontend_checkTicket', $codeObj );
128 return $codeObj;
129 }
130
131 private function addNewUsedEntryToMetaObject($metaObj) {
132 // darf auf used setzen, die letzte IP wird genutzt.
133 if (!isset($metaObj['used'])) $metaObj['used'] = [];
134 $metaObj['used']['reg_request'] = date("Y-m-d H:i:s", current_time("timestamp"));
135 $metaObj['used']['reg_request_tz'] = date_default_timezone_get();
136 $metaObj['used']['reg_ip'] = $this->getCore()->getRealIpAddr();
137 if ($this->MAIN->getOptions()->isOptionCheckboxActive('oneTimeUseOfRegisterCodeWPuser')) {
138 $metaObj['used']['reg_userid'] = get_current_user_id();
139 }
140 $metaObj = apply_filters( $this->MAIN->_add_filter_prefix.'frontend_addNewUsedEntryToMetaObject', $metaObj );
141 return $metaObj;
142 }
143
144 private function addJSRedirectToObject($codeObj) {
145 $url = $this->MAIN->getTicketHandler()->getUserRedirectURLForCode($codeObj);
146
147 // füge die in das codeobj ein
148 if (!empty($url)) {
149 $optionBtnLabel = esc_attr($this->MAIN->getOptions()->getOptionValue('userJSRedirectBtnLabel'));
150 if(!isset($codeObj['_retObject'])) $codeObj['_retObject'] = [];
151 $codeObj['_retObject']['userJSRedirect'] = ['url'=>$url, 'btnlabel'=>$optionBtnLabel];
152 }
153
154 return $codeObj;
155 }
156
157 private function getJSRedirect($codeObj) {
158 if ($this->MAIN->getOptions()->isOptionCheckboxActive('userJSRedirectActiv')) {
159 if ($codeObj['_valid'] == 1) {
160 $codeObj = $this->addJSRedirectToObject($codeObj);
161 } else if ($codeObj['_valid'] == 3) { // is registered already
162 if ($this->MAIN->getOptions()->isOptionCheckboxActive('userJSRedirectIfSameUserRegistered')) { //
163 $codeObj = $this->addJSRedirectToObject($codeObj);
164 }
165 }
166 }
167 return $codeObj;
168 }
169
170 public function countConfirmedStatus($codeObj, $force=false) {
171 if (isset($codeObj['aktiv']) && $codeObj['aktiv'] == 1) {
172 if ((isset($codeObj['_valid']) && $codeObj['_valid'] == 1) || $force) {
173 $metaObj = [];
174 if (isset($codeObj["metaObj"])) {
175 $metaObj = $codeObj["metaObj"];
176 } else {
177 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
178 }
179 $confirmedCount = isset($metaObj['confirmedCount']) ? intval($metaObj['confirmedCount']) : 0;
180 if ($confirmedCount == 0) {
181 $metaObj['validation']['first_success'] = date("Y-m-d H:i:s", current_time("timestamp"));
182 $metaObj['validation']['first_success_tz'] = wp_timezone_string();
183 $metaObj['validation']['first_ip'] = $this->getCore()->getRealIpAddr();
184 }
185 $metaObj['validation']['last_success'] = date("Y-m-d H:i:s", current_time("timestamp"));
186 $metaObj['validation']['last_success_tz'] = wp_timezone_string();
187
188 $metaObj['confirmedCount'] = $confirmedCount + 1;
189 $codeObj['meta'] = $this->getCore()->json_encode_with_error_handling($metaObj);
190 $this->getDB()->update("codes", ["meta"=>$codeObj['meta']], ['id'=>$codeObj['id']]);
191 if (isset($codeObj["metaObj"])) {
192 $codeObj["metaObj"] = $metaObj;
193 }
194 }
195 }
196 do_action( $this->MAIN->_do_action_prefix.'frontend_countConfirmedStatus', $codeObj, $force );
197 return $codeObj;
198 }
199
200 private function setStatusMessages($codeObj) {
201 if(!isset($codeObj['_retObject'])) $codeObj['_retObject'] = [];
202 switch ($codeObj['_valid']) {
203 case 0:
204 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
205 break;
206 case 1:
207 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
208 break;
209 case 2:
210 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
211 break;
212 case 3:
213 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
214 break;
215 case 4:
216 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
217 break;
218 case 5:
219 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
220 break;
221 case 6:
222 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
223 break;
224 case 7:
225 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
226 break;
227 case 8:
228 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage'.$codeObj['_valid'])];
229 break;
230 }
231 if (isset($codeObj['_retObject']['message']['text']) && !empty($codeObj['_retObject']['message']['text'])) {
232 $codeObj['_retObject']['message']['text'] = $this->getCore()->replaceURLParameters($codeObj['_retObject']['message']['text'], $codeObj);
233 }
234 $codeObj = apply_filters( $this->MAIN->_add_filter_prefix.'frontend_setStatusMessages', $codeObj );
235 return $codeObj;
236 }
237
238 private function displayMessageValue($codeObj) {
239 if ($this->MAIN->getOptions()->isOptionCheckboxActive('displayUserRegistrationOfCode')) {
240 if ($codeObj['_valid'] == 3) {
241 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
242 if (isset($metaObj['user']) && isset($metaObj['user']['value'])) {
243 if(!isset($codeObj['_retObject'])) $codeObj['_retObject'] = [];
244 $text = "";
245 if (isset($codeObj['_retObject']['message']) && !empty($codeObj['_retObject']['message']['text'])) $text = $codeObj['_retObject']['message']['text']."<br>";
246 $preText = $this->MAIN->getOptions()->getOptionValue('displayUserRegistrationPreText');
247 $afterText = $this->MAIN->getOptions()->getOptionValue('displayUserRegistrationAfterText');
248 if (!empty($preText)) $text .= $preText."<br>";
249 $text .= htmlentities($metaObj['user']['value']);
250 if (!empty($afterText)) $text .= "<br>".$afterText;
251 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$text];
252 }
253 }
254 }
255
256 if ($codeObj['_valid'] == 1) {
257 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
258
259 $date_format = $this->MAIN->getOptions()->getOptionDateFormat();
260
261 if ($codeObj['list_id'] != 0) {
262 if ($this->MAIN->getOptions()->isOptionCheckboxActive('displayCodeListDescriptionIfValid')) {
263 // hole code list
264 $listObj = $this->getCore()->getListById($codeObj['list_id']);
265 $metaObj = $this->getCore()->encodeMetaValuesAndFillObjectList($listObj['meta']);
266 // setze message
267 if (isset($metaObj['desc']) && !empty($metaObj['desc'])) {
268 if(!isset($codeObj['_retObject'])) $codeObj['_retObject'] = [];
269 $text = "";
270 if (isset($codeObj['_retObject']['message']) && !empty($codeObj['_retObject']['message']['text'])) $text = $codeObj['_retObject']['message']['text']."<br>";
271 $text .= htmlentities($metaObj['desc']);
272 $codeObj['_retObject']['message'] = ['ok'=>true, 'text'=>$text, 'color'=>'', 'weight'=>'normal']; // normale schriftfarbe
273 }
274 }
275 }
276
277 if ($this->MAIN->getOptions()->isOptionCheckboxActive('displayCodeInfoFirstCheck')) {
278 $label = $this->MAIN->getOptions()->getOptionValue('displayCodeInfoFirstCheckLabel');
279 if (!empty($label) && strpos($label, '{VALIDATION-FIRST_SUCCESS}') === false ) {
280 $label .= " {VALIDATION-FIRST_SUCCESS}";
281 }
282 $label = str_replace('{VALIDATION-FIRST_SUCCESS}', date($date_format, strtotime($metaObj['validation']['first_success'])), $label);
283 $label = str_replace('{VALIDATION-FIRST_SUCCESS_TZ}', $metaObj['validation']['first_success_tz'], $label);
284 $codeObj['_retObject']['message']['text'] .= "<br>".$label;
285 }
286
287 if ($this->MAIN->getOptions()->isOptionCheckboxActive('displayCodeInfoLastCheck')) {
288 $label = $this->MAIN->getOptions()->getOptionValue('displayCodeInfoLastCheckLabel');
289 if (!empty($label) && strpos($label, '{VALIDATION-LAST_SUCCESS}') === false ) {
290 $label .= " {VALIDATION-LAST_SUCCESS}";
291 }
292 $label = str_replace('{VALIDATION-LAST_SUCCESS}', date($date_format, strtotime($metaObj['validation']['last_success'])), $label);
293 $label = str_replace('{VALIDATION-LAST_SUCCESS_TZ}', $metaObj['validation']['last_success_tz'], $label);
294 $codeObj['_retObject']['message']['text'] .= "<br>".$label;
295 }
296
297 if ($this->MAIN->getOptions()->isOptionCheckboxActive('displayCodeInfoConfirmedCount')) {
298 $label = $this->MAIN->getOptions()->getOptionValue('displayCodeInfoConfirmedCountLabel');
299 if (!empty($label) && strpos($label, '{CONFIRMEDCOUNT}') === false ) {
300 $label .= " {CONFIRMEDCOUNT}";
301 }
302 $label = str_replace('{CONFIRMEDCOUNT}', intval($metaObj['confirmedCount']), $label);
303 $codeObj['_retObject']['message']['text'] .= "<br>".$label;
304 }
305 }
306
307 if ($codeObj['_valid'] == 7) {
308 $codeObj['_retObject']['message'] = ['ok'=>false, 'text'=>$this->MAIN->getOptions()->getOptionValue('textValidationMessage7')];
309 }
310
311 if (isset($codeObj['_retObject']['message']['text']) && !empty($codeObj['_retObject']['message']['text'])) {
312 $codeObj['_retObject']['message']['text'] = $this->getCore()->replaceURLParameters($codeObj['_retObject']['message']['text'], $codeObj);
313 }
314 $codeObj = apply_filters( $this->MAIN->_add_filter_prefix.'frontend_displayMessageValue', $codeObj );
315 return $codeObj;
316 }
317
318 public function checkCode($data) {
319 if (!isset($data['code']) || trim($data['code']) == "") throw new Exception("#1001 code parameter is missing");
320
321 $data = apply_filters($this->MAIN->_add_filter_prefix.'beforeCheckCodePre', $data);
322 if ($this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'beforeCheckCodePre')) {
323 $data = $this->MAIN->getPremiumFunctions()->beforeCheckCodePre($data);
324 }
325
326 $data = $this->checkIfOnlyLoggedInIsAffected($data);
327
328 if ($this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'beforeCheckCode')) {
329 $data = $this->MAIN->getPremiumFunctions()->beforeCheckCode($data);
330 }
331 $data = apply_filters($this->MAIN->_add_filter_prefix.'beforeCheckCode', $data);
332
333 $valid = 1;
334 try {
335 $codeObj = $this->getCore()->retrieveCodeByCode($data['code'], false);
336 $codeObj['_data_code'] = urlencode(trim($data['code']));
337 if ($codeObj['aktiv'] != 1) $valid = 2;
338 if ($codeObj['aktiv'] == 2) $valid = 7; // stolen
339
340 if ($valid == 1 && $codeObj['cvv'] != "") {
341 $valid = 6; // ask for CVV
342 if (isset($data['cvv']) && $data['cvv'] != "") {
343 if (strtoupper($data['cvv']) == strtoupper($codeObj['cvv'])) {
344 $valid = 1;
345 }
346 }
347 }
348
349 if ($valid == 1) {
350 if($this->getCore()->checkCodeExpired($codeObj)) {
351 $valid = 4;
352 } else if($this->getCore()->isCodeIsRegistered($codeObj)) {
353 $valid = 3;
354 }
355 }
356 } catch (Exception $e) {
357 $valid = 0; // not found
358 }
359 $codeObj['_valid'] = $valid;
360 $codeObj['_data_code'] = urlencode(trim($data['code']));
361
362 $codeObj = $this->setStatusMessages($codeObj); // muss später nochmal ausgeführt werden, falls sich das valid nochmal ändert
363
364 if ($this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'afterCheckCodePre')) {
365 $codeObj = $this->MAIN->getPremiumFunctions()->afterCheckCodePre($codeObj);
366 }
367 $codeObj = apply_filters($this->MAIN->_add_filter_prefix.'afterCheckCodePre', $codeObj);
368
369 if (count($codeObj) > 1 && isset($codeObj['id']) && !empty($codeObj['id'])) {
370 if ($codeObj['_valid'] != 6) { // cvv check request
371 // codeObj is found
372 $codeObj = $this->markAsUsed($codeObj);
373 $codeObj = $this->checkTicket($codeObj);
374 $codeObj = $this->getJSRedirect($codeObj);
375 $codeObj = $this->countConfirmedStatus($codeObj);
376 $codeObj = $this->setStatusMessages($codeObj); // nochmal, falls sich das valid nochmal geändert hat
377 $codeObj = $this->displayMessageValue($codeObj);
378 }
379 }
380
381 $this->getCore()->triggerWebhooks($codeObj['_valid'], $codeObj);
382
383 if ($this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'afterCheckCode')) {
384 $codeObj = $this->MAIN->getPremiumFunctions()->afterCheckCode($codeObj);
385 }
386 $codeObj = apply_filters($this->MAIN->_add_filter_prefix.'afterCheckCode', $codeObj);
387
388 $ret = ['valid'=>$codeObj['_valid']];
389 if (isset($codeObj['_retObject'])) $ret['retObject'] = $codeObj['_retObject'];
390 return $ret;
391 }
392
393 public function getOptions() {
394 return $this->MAIN->getOptions()->getOptionsOnlyPublic();
395 }
396
397 private function registerToCode($data) {
398 if(!isset($data['code'])) throw new Exception("#9201 code parameter missing");
399 if(!isset($data['value'])) throw new Exception("#9202 value parameter missing");
400 $codeObj = $this->getCore()->retrieveCodeByCode($data['code']);
401 if ($codeObj['aktiv'] != 1) throw new Exception("#9205 ticket number not correct");
402 if ($this->getCore()->checkCodeExpired($codeObj)) throw new Exception("#9206 ticket expired");
403 if ($this->getCore()->isCodeIsRegistered($codeObj)) throw new Exception("#9207 ticket already taken - cannot register user to this ticket");
404 // speicher registrierung
405 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
406 $metaObj['user']['value'] = htmlentities($data['value']);
407 $metaObj['user']['reg_ip'] = $this->getCore()->getRealIpAddr();
408 $metaObj['user']['reg_approved'] = 1; // auto approval
409 $metaObj['user']['reg_request'] = date("Y-m-d H:i:s", current_time("timestamp"));
410 $metaObj['user']['reg_request_tz'] = date_default_timezone_get();
411 $metaObj['user']['reg_userid'] = 0;
412 if ($this->MAIN->getOptions()->isOptionCheckboxActive('allowUserRegisterCodeWPuserid')) {
413 $metaObj['user']['reg_userid'] = get_current_user_id();
414 }
415 $codeObj['meta'] = $this->getCore()->json_encode_with_error_handling($metaObj);
416 $this->getDB()->update("codes", ["meta"=>$codeObj['meta'], "user_id"=>$metaObj['user']['reg_userid']], ['id'=>$codeObj['id']]);
417 // send webhook if activated
418 $this->getCore()->triggerWebhooks(7, $codeObj);
419 do_action( $this->MAIN->_do_action_prefix.'frontend_registerToCode', $data, $codeObj );
420 return $metaObj;
421 }
422 }
423 ?>