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

Custom Field Callback

Discussion in 'XenForo Development Discussions' started by Mythotical, Aug 15, 2013.

  1. Mythotical

    Mythotical Well-Known Member

    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.
     
  2. Mythotical

    Mythotical Well-Known Member

    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.
     
  3. Mythotical

    Mythotical Well-Known Member

    Ok that was a flop so I'm back to the original issue above.
     

Share This Page