Please Enter a Valid callback method when saving code even listener?

Liam W

in memoriam 1998-2020
I'm trying to make my first xenForo mod, and am having trouble :(

I have tried making a code event listener, I have the file (I followed the tutorial), and I named the class and the function, however when I enter those details into the code event listener thing it gives me an error when I try and save it.

This is my LoadClassController.php file (saved in <forum root>/Library/CPFirewall/Listener):

PHP:
<?
 
class CPFirewall_Listener_LoadClassController
{
        public static function loadClassListener($class, &$extend)
        {
 
                if ($class == 'XenForo_ControllerAdmin_Login')
                {
                        $extend[] = 'CPFirewall_ControllerAdmin_EmailLogin';
                }
 
        }
 
}

When I enter CPFirewall_Listener_LoadClassController :: loadClassListener in the code event listener create page, it gives me an error when I save, saying I have to enter a valid callback method.

Any help? What I am doing wrong? I am very new to xenForo, so yeah ;)
 
I'm trying to make my first xenForo mod, and am having trouble :(

I have tried making a code event listener, I have the file (I followed the tutorial), and I named the class and the function, however when I enter those details into the code event listener thing it gives me an error when I try and save it.

This is my LoadClassListener.php file (saved in <forum root>/Library/CPFirewall/Listener):

PHP:
<?
 
class CPFirewall_Listener_LoadClassController
{
        public static function loadClassListener($class, &$extend)
        {
 
                if ($class == 'XenForo_ControllerAdmin_Login')
                {
                        $extend[] = 'CPFirewall_ControllerAdmin_EmailLogin';
                }
 
        }
 
}

When I enter CPFirewall_Listener_LoadClassController :: loadClassListener in the code event listener create page, it gives me an error when I save, saying I have to enter a valid callback method.

Any help? What I am doing wrong? I am very new to xenForo, so yeah ;)

Change the class name to this:

class CPFirewall_Listener_LoadClassListener

That part should reflect the name of your listener file name.
 
I'm trying to make my first xenForo mod, and am having trouble :(

I have tried making a code event listener, I have the file (I followed the tutorial), and I named the class and the function, however when I enter those details into the code event listener thing it gives me an error when I try and save it.

This is my LoadClassListener.php file (saved in <forum root>/Library/CPFirewall/Listener):

PHP:
<?
 
class CPFirewall_Listener_LoadClassController
{
        public static function loadClassListener($class, &$extend)
        {
 
                if ($class == 'XenForo_ControllerAdmin_Login')
                {
                        $extend[] = 'CPFirewall_ControllerAdmin_EmailLogin';
                }
 
        }
 
}

When I enter CPFirewall_Listener_LoadClassController :: loadClassListener in the code event listener create page, it gives me an error when I save, saying I have to enter a valid callback method.

Any help? What I am doing wrong? I am very new to xenForo, so yeah ;)

Usually this means "could not find the file". 90% of my times my problem is wrong case (uppercase-lowercase, etc), or the file is not in the correct place.

Check that you have

1) <XENFORO_ROOT>/library/CPFirewall/Listener
2) File is named "LoadClassController.php"
3) Class is named CPFirewall_Listener_LoadClassController

4) You enter in the add-on section CPFirewall_Listener_LoadClassController :: loadClassListener

The fact that you typed Library uppercase was already making me nervous :)
 
Usually this means "could not find the file". 90% of my times my problem is wrong case (uppercase-lowercase, etc), or the file is not in the correct place.

Check that you have

1) <XENFORO_ROOT>/library/CPFirewall/Listener
2) File is named "LoadClassController.php"
3) Class is named CPFirewall_Listener_LoadClassListener

The fact that you typed Library uppercase was already making me suspect :)

All of those points have been validated, and I'm still getting the error :(
 
You should use <?php opening tags instead of <?
This shouldn't be the problem if the shorthand is enabled on your server, but it can be disabled on other servers (if you want to release your addon)

Didn't notice I was using the short version!

And they were disabled in XAMPP it would seem! All working now, damn I could kick myself ;)
 
Top Bottom