Last active
December 27, 2015 00:29
-
-
Save cesarmiquel/7238113 to your computer and use it in GitHub Desktop.
Unpublish drupal content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Select all nodes of type article created by anonymous and admin | |
$result = db_select('node', 'n') | |
->fields('n', array('nid')) | |
->condition('type', 'article') | |
->condition('uid', array(0,1), 'IN') | |
->execute(); | |
// go through results and unpublish each article. | |
foreach($result as $row) { | |
$node = node_load($row->nid); | |
print 'Unpublishing: ' . $node->nid . ' - ' . $node->title . "\n"; | |
$node->status = 0; | |
node_save($node); | |
} | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment