silence
Well-known member
Basically I want to create a callback that checks if the input exists in a particular custom profile field. How can I go about doing this since documentation is extremely limited for devs
EDIT
Alright here is what I have so far, honestly I'm not sure this callback would work!
EDIT
Alright here is what I have so far, honestly I'm not sure this callback would work!
PHP:
<?php
class gameDonation
{
function checkGameNames($name, $price, $time)
{
$db = XenForo_Application::get('db');
$results = $db->query("
SELECT `field_value`,`user_id`
FROM `xf_user_field_value`
WHERE field_value = " . $name . "
");
$storedtime = $db->query("
SELECT `last_donation_date`
FROM `merc_donor`
WHERE last_donation_date = " . $time . "
");
if (empty($results) && empty($storedtime))
{
addGameData::gameDataSave($response, $price);
//not a linked user, but it is a new donation!
}
if (empty($results) && (!(empty($storedtime))))
{
return;
}
if (($results[0] == $name) && empty($storedtime))
{
addGameData::gameDataSave($response, $price);
//linked user and a new donation!
}
if (($results[0] == $name) && (!(empty($storedtime))))
{
return;
}
}
}
class addGameData extends Merc_DonationManager_ControllerAdmin_Donation
{
public function gameDataSave(&$response, $price)
{
$this->_assertPostOnly();
$data = $this->_input->filter(array(
'username' => $response[0],
'user_id' => 0,
'amount' => $price,
'anonymous' => 1,
'note' => "Game donation",
'goal_id' => 5,
));
$datetime = $time;
if (empty($data['user_id']))
{
$userModel = $this->getModelFromCache('XenForo_Model_User');
$data['user_id'] = $userModel->getUserIdFromUser($userModel->getUserByName($data['username']));
}
$dw = XenForo_DataWriter::create('Merc_DonationManager_DataWriter_Donation');
$dw->bulkSet($data);
$dw->set('transaction_id', 0);
$dw->save();
}
}
?>