• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Custom Field Callback

Mythotical

Well-known member
#1
Using _postSave() to add points to my xfpoints_currency field. The problem I am having is that when accessing it I have tried the following:
PHP:
  protected function _postSave()
   {
     $visitor = XenForo_Visitor::getInstance();
     $promoModel = $this->_getPromotionModel();
     $userField = XenForo_Model::create('XenForo_Model_UserField');
     $values = $userField->getUserFieldValues($visitor['user_id']);
     $xfpoints_promotion_code = $values['xfpoints_promotion_code'];
     $promo = $promoModel->getCodeByCode($xfpoints_promotion_code));

     if ($xfpoints_promotion_code == $promo['code'])
AND
PHP:
     $promoModel = $this->_getPromotionModel();
     $promo = $promoModel->getCodeByCode($this->get('xfpoints_promotion_code'));

     if ($this->get('xfpoints_promotion_code') == $promo['code'])
Neither works, it returns a null value meaning it is not able to get any data from the database so $xfpoints_promotion_code and $this->get('xfpoints_promotion_code') are invalid and I'm unsure of the proper way to check custom fields against data I pull before awarding points.
 

Mythotical

Well-known member
#2
I may have found a solution as I didn't look at XenForo_DataWriter_User so now I am looking at the method they use there to grab the field and I'll adapt it then test. I'll report back my findings.