Drakeus
Member
I am trying to create a callback to validate the input of a custom user field against a database. I have looked through the few discussions on here for the php callbacks for XF2 but unfortunately have not been able to make it work based on the information I have found. in the admin cp for the call back i am entering:
my file path is /addons/GW2/Callback
and UserField.php is as follows:
I had this working for XF1.5 and am wanting to upgrade my forums to XF2.0 but will not be doing so until i get this to work.
any help would be greatly appreciated.
Code:
GW2\Callback\UserField\gw2::validate
my file path is /addons/GW2/Callback
and UserField.php is as follows:
PHP:
<?php
class GW2\Callback\UserField\gw2{
public static function validate ($field, &$value, &$error){
$servername = "xxxxxxxx";
$username = "xxxxxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "SELECT member FROM gw2_roster WHERE member = '$value'";
$member = $conn->query($sql);
//this Should search the db for $value
if ($member->num_rows > 0)
{
//if rows returned greater than 0 continue with registration
return true;
}
else
{
$error = 'Guild Wars 2 account does not exist in guild please try again later. <br>If you just joined the guild please allow up to 12 hours for API to be queried.';
return false;
}
}
}
I had this working for XF1.5 and am wanting to upgrade my forums to XF2.0 but will not be doing so until i get this to work.
any help would be greatly appreciated.
Last edited: