XF 2.0 XF2 equivalent of rebuildUserFieldCache

abdfahim

Well-known member
Once I change display_group in xf_user_field table and introduce a new custom field group, it does not work until I rebuild User Field Cache. In XF1, I did like
Code:
XenForo_Model::create('XenForo_Model_UserField')->rebuildUserFieldCache();

What is XF2 equivalent? And can I manually rebuild this cache from Admin CP?
 
If you’re using the DataWriter in XF1 to update it or the Entity in XF2 to update it, then it should happen automatically.

Please avoid performing direct database queries as important lifecycle events will be skipped.
 
Upon reading about XF2 entities, it seems like this is mainly useful when I want to perform a regular action on something. But for this particular case, I just need to change this once in my setup file. Do I need to do anything with entities?

Right now I am doing below. Though it changes the database, it is not reflected in the templates. In XF1, I used to call rebuildUserFieldCache after running this query and everything worked fine.

Can someone please guide me how to achieve the same with XF2?

Code:
public function installStep2()
{
    $this->query("UPDATE xf_user_field SET display_group = 'test1'  WHERE field_id IN ('facebook')");
}
 
Last edited:
Back
Top Bottom