How can I do this? Force nodes created by Feeds module to be published even if regular nodes are unpublished by default.


Implement hook_nodeapi() for the 'presave' operation to set the node status to published if there is a new one created by Feeds:

function MODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op === 'presave' && empty($node->nid) && !empty($node->feeds_node_item)) {
    $node->status = 1;
| improve this answer | |
  • I'm going to try this – Matthew Hui Aug 4 '11 at 21:07

Making nodes published is not a problem, the question is how are we going to tell the nodes created by Feeds. The quickest options are

  1. a separate node type for imported content, or
  2. a hidden field that only gets set via Feeds mapping

Assuming none of the quick solutions would fit your scenario, the only actual way to tell Feed-created nodes is the feeds_node_item. After importing a node, it will contain a record for the node, with nid column set to the node id.

Making use of the Rules module, the whole trick is just a matter of an Execute custom PHP code for condition to check if the record is there for the newly created node:

Add new rule

Event: After saving new content

Add a condition

Select the condition to add: Execute custom PHP code

PHP code

$a = db_fetch_array(db_query("select count(*) c from {feeds_node_item}
                              where nid = %d", array($node->nid)));
return $a['c'] != 0;

Add an action

Select an action to add: Publish content

| improve this answer | |

I've done something similar to expose the user status as a mapper; see the patch proposed in Add user status to FeedsUserProcessor, which would be similar.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.