I am having difficulty getting around some perms issue, or finding the right incantation to do so...
I have a content type called Application. It gets some fields filled via my custom module, upon submission. I use the hook_node_insert to do this, as Rules module needs to come along next and use those fields. So within my module I can retrieve and set fields using field_get_value, and then field_attach_update. And that works happily SO LONG AS I AM ADMIN. As soon as a regularly authenticated user tries the process, the final field_attach_update('node', $node) fails, probably because the process is running as a user that doesn't have access to writing the Application (it should be read-only for them!).
So how do I overcome this? Can I temporarily elevate the user doing the PHP work? Or is there another function set I should be using? (I tried with entity_metadata_wrapper, but couldn't get the right incantations to load the fields from my nodes!)
And just to add - I've never used field_attach_update(), ever... and I've been tinkering with entities for a long time. field_attach_update() is one of those functions that are usually called internally by others, so it's better to make use of the higher level node_save() once you have updated the node object.