__('Too many verification code requests. Please try again later.', 'fluent-support') ], 429); } try { $verifcationCode = str_pad(random_int(100123, 900987), 6, 0, STR_PAD_LEFT); } catch (\Exception $e) { $verifcationCode = str_pad(wp_rand(100123, 900987), 6, 0, STR_PAD_LEFT); } $string = $formData['email'] . '-' . wp_generate_uuid4() . wp_rand(1, 99999999); $hash = wp_hash_password($string); $hash = sanitize_title($hash, '', 'display'); $hash .= $formData['email'] . '-' . time(); $data = array( 'login_hash' => $hash, 'status' => 'issued', 'email' => strtolower(trim($formData['email'])), 'ip_address' => Helper::getIp(), 'use_type' => 'signup_verification', 'used_count' => 0, 'two_fa_code_hash' => wp_hash_password($verifcationCode), 'valid_till' => gmdate('Y-m-d H:i:s', current_time('timestamp') + self::CODE_TTL_SECONDS), 'created_at' => current_time('mysql'), 'updated_at' => current_time('mysql') ); $savedRecord = Meta::create([ 'object_type' => 'fs_login_hashes', 'key' => $hash, 'value' => maybe_serialize($data) ]); if (!$savedRecord || !$savedRecord->exists) { wp_send_json([ 'message' => __('Unable to send verification code. Please try again later.', 'fluent-support') ], 500); } // translators: %s is the site name $mailSubject = apply_filters("fluent_support/signup_verification_mail_subject", sprintf(__('Your registration verification code for %s', 'fluent-support'), get_bloginfo('name'))); $pStart = '

'; // translators: %s is the user's first name $message = $pStart . sprintf(__('Hello %s,', 'fluent-support'), Arr::get($formData, 'first_name')) . '

' . $pStart . __('Thank you for registering with us! To complete the setup of your account, please enter the verification code below on the registration page.', 'fluent-support') . '

' . // translators: %s is the verification code $pStart . '' . sprintf(__('Verification Code: %s', 'fluent-support'), $verifcationCode) . '

' . '
' . $pStart . __('This code is valid for 10 minutes and is meant to ensure the security of your account. If you did not initiate this request, please ignore this email.', 'fluent-support') . '

'; $message = apply_filters('fluent_support/signup_verification_email_body', $message, $verifcationCode, $formData); $data = [ 'body' => $message, 'pre_header' => __('Activate your account', 'fluent-support'), 'show_footer' => false ]; $message = Helper::loadView('notification', $data); $headers = array('Content-Type: text/html; charset=UTF-8'); \wp_mail($formData['email'], $mailSubject, $message, $headers); ob_start(); ?>