On Wed, 2011-03-23 at 15:28 -0400, Ted wrote:
On 3/23/2011 12:18 PM, Xavier Bestel wrote:
How can I bypass the permissions system to make node_save() work ? I'm using Drupal 6.
user_access caches perms, otherwise you would be able to temporarily add a role with 'administer nodes'. Instead, you'll need to swap out the global $user for uid 1 temporarily (and rename your local $user var). After you're done with the node_save, remember to swap the old $user back.
Great !
Would something like that work (I'm not a true drupalist;) ?
global $user; $usersave = $user; $user = user_load(1);
... do stuff with node_save() ...
$user = $usersave;
At first glance that looks okay. Give it a shot!
Works very well. Thank you Ted !
Xav