Благодарочка Designer за халявный рабочий код для Opencart 2.0.3.1.
Аналогично добавил капчу в формы регистрации.
В файле
# 1. catalog/controller/account/register.php
перед строкой
$data['column_left'] = $this->load->controller('common/column_left');
добавил
if ($this->config->get('config_google_captcha_status')) {
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
} else {
$data['site_key'] = '';
}
перед строкой
// Customer Group
вставил
if ($this->config->get('config_google_captcha_status') && empty($this->error['warning'])) {
if (isset($this->request->post['g-recaptcha-response'])) {
$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
$recaptcha = json_decode($recaptcha, true);
if (!$recaptcha['success']) {
$this->error['warning'] = $this->language->get('error_captcha');
}
} else {
$this->error['warning'] = $this->language->get('error_captcha');
}
}
В файле
# 2. catalog/view/theme/ВАША ТЕМА/template/account/register.tpl
перед строкой
<?php if ($text_agree) { ?>
добавил:
<?php if ($site_key) { ?>
<div class="form-group">
<div class="col-sm-12">
<div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
</div>
</div>
<?php } ?>
P.S. Спамерам - мой пламенный!