1

enter image description here

I want to used this key in my Custom Module so how to get this this key using block.

I create a form on frontend which has a Recaptcha V2. How to used default keys for this Form.

And I also need to check is enable for Frontend (Backend) or not.

Thanks

2

1 Answer 1

3

Try with the below code in your block and let me know.

<?php
namespace Vendor\ModuleName\Block;    
class TestClassName extends \Magento\Framework\View\Element\Template
{

    const XML_PATH_ENABLED_FRONTEND = 'msp_securitysuite_recaptcha/frontend/enabled';
    const XML_PATH_PUBLIC_KEY       = 'msp_securitysuite_recaptcha/general/public_key';


    /**
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    */
    public function __construct(
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig       
    ) {
        $this->scopeConfig = $scopeConfig;
    }

    public function getFrontendCaptchaEnabled()
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_ENABLED_FRONTEND,
            ScopeInterface::SCOPE_STORE
        );
    }

    public function getSecurityCaptchaKey()
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_PUBLIC_KEY,
            ScopeInterface::SCOPE_STORE
        );
    }
}

if you would like to call the above method in your template file use this syntax

$block->getSecurityCaptchaKey();

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.