Hide recaptcha in manage subscription form

[MAILPOET-3459]
This commit is contained in:
wxa
2021-03-09 13:20:08 +03:00
committed by Veljko V
parent 2566ebb13c
commit 3fd379a72d
2 changed files with 6 additions and 3 deletions

View File

@ -58,11 +58,14 @@ class Renderer {
} }
} }
public function renderBlocks(array $blocks = [], array $formSettings = [], bool $honeypotEnabled = true): string { public function renderBlocks(array $blocks = [], array $formSettings = [], bool $honeypotEnabled = true, bool $captchaEnabled = true): string {
// add honeypot for spambots // add honeypot for spambots
$html = ($honeypotEnabled) ? $this->renderHoneypot() : ''; $html = ($honeypotEnabled) ? $this->renderHoneypot() : '';
foreach ($blocks as $key => $block) { foreach ($blocks as $key => $block) {
if ($block['type'] === FormEntity::SUBMIT_BLOCK_TYPE && $this->settings->get('captcha.type') === Captcha::TYPE_RECAPTCHA) { if ($captchaEnabled
&& $block['type'] === FormEntity::SUBMIT_BLOCK_TYPE
&& $this->settings->get('captcha.type') === Captcha::TYPE_RECAPTCHA
) {
$html .= $this->renderReCaptcha(); $html .= $this->renderReCaptcha();
} }
if (in_array($block['type'], [FormEntity::COLUMN_BLOCK_TYPE, FormEntity::COLUMNS_BLOCK_TYPE])) { if (in_array($block['type'], [FormEntity::COLUMN_BLOCK_TYPE, FormEntity::COLUMNS_BLOCK_TYPE])) {

View File

@ -85,7 +85,7 @@ class ManageSubscriptionFormRenderer {
'email' => $subscriber->email, 'email' => $subscriber->email,
'token' => $this->linkTokens->getToken($subscriber), 'token' => $this->linkTokens->getToken($subscriber),
'editEmailInfo' => __('Need to change your email address? Unsubscribe here, then simply sign up again.', 'mailpoet'), 'editEmailInfo' => __('Need to change your email address? Unsubscribe here, then simply sign up again.', 'mailpoet'),
'formHtml' => $this->formRenderer->renderBlocks($form, [], $honeypot = false), 'formHtml' => $this->formRenderer->renderBlocks($form, [], $honeypot = false, $captcha = false),
'formState' => $formState, 'formState' => $formState,
]; ];