function mo2f_create_customer($current_user) { delete_user_meta($current_user->ID, 'mo2f_sms_otp_count'); delete_user_meta($current_user->ID, 'mo2f_email_otp_count'); $customer = new Customer_Setup(); $customerKey = json_decode($customer->create_customer(), true); if ($customerKey['status'] == 'ERROR') { update_option('mo2f_message', $customerKey['message']); $this->mo_auth_show_error_message(); } else { if (strcasecmp($customerKey['status'], 'CUSTOMER_USERNAME_ALREADY_EXISTS') == 0) { //admin already exists in miniOrange $content = $customer->get_customer_key(); $customerKey = json_decode($content, true); if (json_last_error() == JSON_ERROR_NONE) { if (array_key_exists("status", $customerKey) && $customerKey['status'] == 'ERROR') { update_option('mo2f_message', $customerKey['message']); $this->mo_auth_show_error_message(); } else { update_option('mo2f_customerKey', $customerKey['id']); update_option('mo2f_api_key', $customerKey['apiKey']); update_option('mo2f_customer_token', $customerKey['token']); update_option('mo2f_app_secret', $customerKey['appSecret']); update_option('mo2f_miniorange_admin', $current_user->ID); delete_option('mo2f_password'); update_option('mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', get_option('mo2f_email')); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $enduser = new Two_Factor_Setup(); $enduser->mo2f_update_userinfo(get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true), 'OUT OF BAND EMAIL', null, 'API_2FA', true); update_user_meta($current_user->ID, 'mo2f_email_verification_status', true); update_option('mo2f_message', 'Your account has been retrieved successfully. <b>Email Verification</b> has been set as your default 2nd factor method. <a href=\\"admin.php?page=miniOrange_2_factor_settings&mo2f_tab=mobile_configure\\" >Click Here </a>to configure another 2nd factor authentication method.'); $this->mo_auth_show_success_message(); } } else { update_option('mo2f_message', 'Invalid email or password. Please try again.'); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_VERIFY_CUSTOMER'); $this->mo_auth_show_error_message(); } } else { update_option('mo2f_customerKey', $customerKey['id']); update_option('mo2f_api_key', $customerKey['apiKey']); update_option('mo2f_customer_token', $customerKey['token']); update_option('mo2f_app_secret', $customerKey['appSecret']); update_option('mo2f_miniorange_admin', $current_user->ID); delete_option('mo2f_password'); update_option('mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', get_option('mo2f_email')); update_option('mo2f_message', 'Your account has been created successfully. '); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $enduser = new Two_Factor_Setup(); $enduser->mo2f_update_userinfo(get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true), 'OUT OF BAND EMAIL', null, 'API_2FA', true); update_user_meta($current_user->ID, 'mo2f_email_verification_status', true); update_option('mo2f_message', 'Your account has been created successfully. <b>Email Verification</b> has been set as your default 2nd factor method. <a href=\\"admin.php?page=miniOrange_2_factor_settings&mo2f_tab=mobile_configure\\" >Click Here </a>to configure another 2nd factor authentication method.'); $this->mo_auth_show_success_message(); header('Location: admin.php?page=miniOrange_2_factor_settings&mo2f_tab=mo2f_pricing'); } } }