XF 2.1 Core HoneyPots

Problem is, when someone registers, and fills out one of the honeypots that have a name of "accepts" the registration is not denied, which it should be.
This is probably because you are extending the Register class, and not the RegisterForm service. You are also defining 2 classes in the same PHP file, which is wrong.

Change your extension definition to this:
Code:
Base class name: XF\Service\User\RegisterForm
Extension class name: SPAMINATOR\XF\Service\User\RegisterForm

Then delete your previous PHP file.

Create a new PHP file: src/addons/SPAMINATOR/XF/Service/User/RegisterForm.php
PHP:
<?php

namespace SPAMINATOR\XF\Service\User;

class RegisterForm extends XFCP_RegisterForm
{
    protected $spaminatorHashedFields = [
        'accepts'
    ];

    protected $spaminatorHoneyPotFields = [
        'accepts_hp'
    ];
    
    public function __construct(\XF\App $app, \XF\Session\Session $session = null)
    {
        parent::__construct($app, $session);
        
        $this->hashedFields = array_merge($this->hashedFields, $this->spaminatorHashedFields);
        $this->honeyPotFields = array_merge($this->honeyPotFields, $this->spaminatorHoneyPotFields);
    }
}
 
This is probably because you are extending the Register class, and not the RegisterForm service. You are also defining 2 classes in the same PHP file, which is wrong.

Change your extension definition to this:
Code:
Base class name: XF\Service\User\RegisterForm
Extension class name: SPAMINATOR\XF\Service\User\RegisterForm

Then delete your previous PHP file.

Create a new PHP file: src/addons/SPAMINATOR/XF/Service/User/RegisterForm.php
PHP:
<?php

namespace SPAMINATOR\XF\Service\User;

class RegisterForm extends XFCP_RegisterForm
{
    protected $spaminatorHashedFields = [
        'accepts'
    ];

    protected $spaminatorHoneyPotFields = [
        'accepts_hp'
    ];
   
    public function __construct(\XF\App $app, \XF\Session\Session $session = null)
    {
        parent::__construct($app, $session);
       
        $this->hashedFields = array_merge($this->hashedFields, $this->spaminatorHashedFields);
        $this->honeyPotFields = array_merge($this->honeyPotFields, $this->spaminatorHoneyPotFields);
    }
}

Thanks, I'll check this out later today after work.
 
Top Bottom