I am importing/updating nodes from a web service using node_save. One feature that I want to achieve is when the imported node is changed locally, it should not receive any further updates from the web service.
So, what I want to achieve is:
- Detect when a node has been updated
- If the update was carried out by a user submitting a form (as oppose to programmatically)
- Then flag that this node should receive no further updates form the web service (I don’t need any assistance with this part)
I wanted to use hook_node_update but I’m not sure how to tell whether the update was carried out by a user submitting a form.
Any suggestions?
During CREATION of node by user (initial setup):
Create a hidden field for nodes with default value to be set to “submitted by user“. As its a hidden field it wont be available in the node edit form, but still it will carry the default value with it.
UPDATING of node by user:
Use hook_form_alter to set the value of our hidden input to “submitted by user“.
During CREATE/UPDATE of a node using webservice:
When creating a node programmatically update the hidden field value with “submitted by webservice“.
Now in hook_node_update you can check for this hidden field value and take decisions accordingly.