UserField callback

blackvoid

Active member
How should the userfield callback function look. Ive found out that the class should extend XenForo_Model_UserField, but since I haven't a documentation for XenForo which shows which function I should extend and function variables

Currently the class looks like this.

PHP:
<?php
 
class DynamicEffect_Minecraft extends XenForo_Model_UserField
    static public function verifyAccountName(&$accountName, &$error)
    {
        $url = 'http://www.minecraft.net/haspaid.jsp?user='.$accountName;
        $contents = trim(file_get_contents($url));
        if($contents == 'false')
        {
            $error = new XenForo_Phrase('no_paid_minecraft_account');
            return true;
        }    else    {
            return true;
        }
    }
}
 
no, the callback function is ONLY for validating and doesn't have to extend userfield model.

if you check the code
PHP:
case 'callback':
                            $matched = call_user_func_array(
                                array($field['match_callback_class'], $field['match_callback_method']),
                                array($field, &$value, &$error)
                            );
you'll see that you need 3 params => field, value and if necessary => the error reference
 
no, the callback function is ONLY for validating and doesn't have to extend userfield model.

if you check the code
PHP:
case 'callback':
                            $matched = call_user_func_array(
                                array($field['match_callback_class'], $field['match_callback_method']),
                                array($field, &$value, &$error)
                            );
you'll see that you need 3 params => field, value and if necessary => the error reference
Thank you, got it working.
 
Bumping with the code that works successfully incase someone wants it! :p
PHP:
<?php
 
class CustomCallback_ProfileField_MineCraft
{
    public static function verifyAccountName($field, &$accountName, &$error)
    {
        $url = 'https://www.minecraft.net/haspaid.jsp?user=' . $accountName;
        $contents = trim(file_get_contents($url));
 
        if($contents == 'false')
        {
            $error = "You cannot link a Minecraft account that hasn't purchased the game!";
            return false;
        }
        else
        {
            return true;
        }
    }
}
 
Top Bottom