On my site, user profiles are not public; the anonymous user does not have permission to access them. However, I want to send a view containing a list of member profiles in an email with Rules Scheduler. I am attaching the view to the email with
views_embed_view(). However, the view content is not displayed because Rules Scheduler use cron, which embeds the view as anonymous user.
So my first thought was to somehow run cron as an admininistrator, but the Drupal documentation states this:
Running cron as an authenticated user (Drupal 6 and earlier only)
If triggering cron.php via the methods above, cron tasks will run as the anonymous user. For most cases this should be fine, but if Drupal cron has been customized to include tasks that must run as a certain site user (e.g. custom logic has been implemented in
hook_cron()that requires special user permissions), the following script may be useful. This script authenticates a user of your choosing before calling cron.php.
Note that as of Drupal 7, cron always runs as an anonymous user, so this will not work in Drupal 7 and later versions!
It doesn't give the reason why, but I assume this is some kind of security issue, and there is no alternative listed. Is it flat-out impossible to run cron as an admin in Drupal 7+?