Jump to content

[FIX] How to make "CAPTCHA Pro by Anvanto" work on PrestaShop 9+


Recommended Posts

Hello everyone,

If you've recently upgraded to PrestaShop 9 and tried to install the "CAPTCHA Pro: reCAPTCHA, Cloudflare - Anti fake & spam" module by Anvanto, you may have run into a fatal "HTTP 500 error" when trying to access its configuration page.

This happens because the module uses some outdated functions that were removed in newer versions of PrestaShop. The good news is that the fix is very simple and only requires editing one file.

Here’s a step-by-step guide to get it working.

The Problem

The module's admin controller (AdminAncaptchaSettingsController.php) calls two deprecated methods that cause PrestaShop to crash:

$this->addJquery(); - This function is no longer needed as jQuery is loaded automatically in the back office.

parent::l(); - The module uses an old method for handling translations within a controller.

The Solution: How to Fix the Errors

You will need to edit one file. You can do this via FTP or the File Manager in your hosting panel.

File to Edit: /modules/ancaptcha/controllers/admin/AdminAncaptchaSettings.php

Fix #1: The addJquery Error

This is the first error you will likely encounter.

Open the AdminAncaptchaSettings.php file.

Navigate to the setMedia function, which should be around line 43.

Find this line of code:

$this->addJquery();

Comment out or delete that line. The easiest way is to add // in front of it, like this:

// $this->addJquery();

Your setMedia function should now look like this:

public function setMedia($isNewTheme = false) { parent::setMedia($isNewTheme); // $this->addJquery(); $this->js_files[] = _MODULE_DIR_ . 'ancaptcha/views/js/back_settings.js'; }

Fix #2: The l() Translation Error

After fixing the first error, you will likely see a new one related to the l() method.

In the same file (AdminAncaptchaSettings.php), find the l() function, which should be around line 36.

The original function looks like this:

public function l($string, $class = null, $addslashes = false, $htmlentities = true) { return parent::l($string, pathinfo(__FILE__, PATHINFO_FILENAME), $addslashes, $htmlentities); }

You need to change the way it calls the translation method. Replace the entire function with this corrected version:

public function l($string, $class = null, $addslashes = false, $htmlentities = true) { return $this->module->l($string, pathinfo(__FILE__, PATHINFO_FILENAME)); }

This new code correctly calls the translation function through the module instance ($this->module->l) instead of using the outdated parent::l.

Final Step:

Save the changes to the AdminAncaptchaSettings.php file and upload it back to your prestashop. Now, clear your PrestaShop cache (under Advanced Parameters > Performance) and refresh the module's configuration page.

Everything should now be working correctly! Hope this helps others who face the same issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...