Reputation: 14568
I am trying to delete some CCK nodes in Drupal using a standalone PHP script while logged in as anonymous user
if(empty($total_deals_for_this_pl)){
$node_nid = $single_result['nid'];
global $user;
$original_user = $user;
$user = user_load(1);
print $node_nid."<br>";
node_delete($node_nid);
$user = $original_user;
}
I am able to retrieve all the nid's successfully but the nodes are not getting deleted. I am loading Drupal as follows
chdir('C:\wamp\www\mysite\platform'); //my drupal resides here
require_once './includes/bootstrap.inc';
include_once './includes/common.inc';
Upvotes: 0
Views: 1085
Reputation: 2308
Node_delete()
has an access check for delete permissions inside it.
Test again with anonymous users given permission to delete nodes.
Also try adding
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
If that doesn't work you could try up to the session phase:
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
and finally the full dealio:
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Upvotes: 3
Reputation: 3205
Three options:
Upvotes: 2