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

XF 1.2 Updating custom field values

Discussion in 'XenForo Questions and Support' started by dknife, Mar 21, 2014.

  1. dknife

    dknife Active Member

    My new website I have XenForo as the member authentication and session manager. I have a custom field created in XF with 3 options, the values being 1,2 and 3.

    I have the same field in my own tables outside of XenForo keeping track of this particular setting for the users. I've just added in the function for them to change this option in the main site and I am having issues manually updating the value in the xf_user_field_value table. This is my SQL

    INSERT IGNORE INTO xf_user_field_value (user_id, field_id, field_value) SELECT xf_id, 'necromunda_ruleset', ruleset FROM necro_profile WHERE id = 1 ON DUPLICATE KEY UPDATE field_value = 3
    This query works and the correct value is updated in the table for the particular user and when I go into the profile on the admin backend it shows the correct setting for the custom field as well. However on the forums itself where I have the field setting displayed (user area in message) it doesn't change what is displayed for the user. Simply entering the password for the user in the admin section and saving without changing anything will make the forum display for that field correct.

    Am I missing something obvious?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That is because those values are cached in xf_user_profile.custom_fields. Editing and saving a user in the Admin CP prompts a rebuild of that cache.
  3. dknife

    dknife Active Member

    Well that explains it. Is there an existing function I can tap into to process the field value change and update the cache?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The user datawriter:


    setCustomFields() can be used.

    For example usage see this action:

    SAS1024 and dknife like this.

Share This Page