Quantcast
Channel: User anschauung - Stack Overflow
Viewing all articles
Browse latest Browse all 40

Running hook_cron with administrator privileges in Drupal 6

$
0
0

Is there a way to allow hook_cron to run with administrator privileges -- e.g a sort of sudo hook_cron() as it were?

This question is a follow up to my earlier question trying to diagnose why hook_cron() functions invoked by /drupal/cron.php run differently that the same functions invoked by /admin/reports/status/run-cron.

My particular function (call it foo_cron()) updates user profiles as part of its nightly duties. But, /drupal/cron.php apparently runs as an anonymous user. Anonymous users cannot modify user profile fields in this site, for obvious reasons, so this part of the script fails.

I know I can work around this by modifying profile_fields directly using SQL, but that feels like an ugly hack, and could be tough to maintain if I start doing this in multiple modules.

Is the a way, within the existing Drupal functions and framework, to make certain foo_cron() jobs run with privs that we normally only give administrators, such as updating profiles?

This particular site is running Drupal 6.1.3.


Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>