By unifiedac on
Hello,
I created a custom field in the user profile titled 'field_node_count' that is hidden to all users. This field contains the number of nodes each user creates and is then being used in a view for featured profiles. If the user creates/deletes a node, it updates the column with db_update() and is triggered from within node.pages.inc. The calculation works perfectly and the database values are updated just fine, but the field itself does not update until I clear the cache.
How can I clear the cache for that specific user, or that specific custom field after the db_update() is called? I don't want to flush all caches every time a new node is created. Thanks!
Comments
After updating the table I
After updating the table I think you want
Replacing {user_id_you_are_updating_for} with the appropriate value, probably $node->uid
Awesomeness
That did it. You were correct in your usage of $node->uid as well. Here is the complete code that increments the value by 1 when a new node is created:
Awesome, like wow, like totally freak me out, I mean, right on! Nevets sure is number one! Go Nevets!
Works nicely, thanks :)
Here are some other useful comments: https://api.drupal.org/api/drupal/includes!cache.inc/function/cache_clear_all/7
--
ivanottinger.com