Force updating a user's custom user field

Jake Hakoda Shirley

Active member
Hey guys, on the back end of things I am running a cron tab that syncs user's stats with a custom user field for easy display on the forum. My issue is that when I alter the values in the database, they aren't updated on the forum end until I 'edit' the user and save the newly loaded values in the Admin CP. Is there a cache that keeps all of the user field values, and if so, how can I automatically rebuild that.
 
Yeah, it's cached in xf_user_profile.custom_fields. The cache can be rebuilt by running this:

Admin CP -> Tools -> Rebuild Caches -> Rebuild User Caches

This is the code if you want to create this in your cron:

library/XenForo/CacheRebuilder/User.php
 
Yeah, it's cached in xf_user_profile.custom_fields. The cache can be rebuilt by running this:

Admin CP -> Tools -> Rebuild Caches -> Rebuild User Caches

This is the code if you want to create this in your cron:

library/XenForo/CacheRebuilder/User.php

Hey Jake, my server host offers self-defined cron jobs, so that's what I have been using to do a lot of my automated server stuff. When I 'include' that PHP file, I am getting the following error:
Code:
Fatal error: Class 'XenForo_CacheRebuilder_Abstract' not found in /home/hungeradmin/hungercraft.net/library/XenForo/CacheRebuilder/User.php on line 8

Do I need to run this script from within XenForo, or is there some what I can run it from an external script?
 
Yeah it's not gonna work like that. If your cron is a PHP script that initializes the XF application then you can use the classes and stuff. If you are manually manipulating the database (ie no datawriters) then refer to this function for code that you can use:

XenForo_Model_UserField::getUserFieldValues

This function simply queries the fields for the specified user_id and puts them into an array. The array that is returned by this function is then serialized, and that is what is written to xf_user_profile.custom_fields.
 
Yeah it's not gonna work like that. If your cron is a PHP script that initializes the XF application then you can use the classes and stuff. If you are manually manipulating the database (ie no datawriters) then refer to this function for code that you can use:

XenForo_Model_UserField::getUserFieldValues

This function simply queries the fields for the specified user_id and puts them into an array. The array that is returned by this function is then serialized, and that is what is written to xf_user_profile.custom_fields.

While that is a useful function if I needed the info somewhere else, I am merely trying to manually update the user's custom user fields (xf_user_field_value table values) and have them display like they normally would. Is there a way I can integrate my external PHP script into an internal cron job that invokes the DataWriter->revuildCustomFields() function?

Sorry, while I have worked a little bit with pages, I am completely new to this area of XenForo.
 
Top Bottom