How can I get the content of a mini panel that is limited to admin-only access using a scheduled rules component? I'm using Rules to e-mail myself the content of a Mini Panel, which contains several views that are restricted to admin-only access.

I am using a component (Action set) that consists of two actions:


Send e-mail 
Schedule component evaluation (re-schedule the same component to be evaluated the following day)


For Send e-mail, the body of my message looks like this (based on this code):

&lt;?php $block = module_invoke('panels_mini', 'block_view', 'admin_user_role_statistics'); print $block['content']; ?&gt;


When I first triggered this component (using a rule that I created to trigger the component for the first time by viewing a user profile), I was logged in as an administrator, so the e-mail I received shows all of the content of the mini panel as I expected.  However, the following day, when the scheduled component was evaluated, the body of the e-mail message was blank, presumably because it was not sent by an admin user.

I re-enabled the rule to trigger the component and tried it as a non-admin user: the message body was empty.  I then tried it as an administrator: the message had the full content.

So, what can I do to make sure the component is evaluated as if triggered by an admin user?
The problem seems to be an anonymous user triggering the component and since you want an admin user to run the component, you will have to impersonate the admin user.

Try this code inside your components to impersonate the admin user :

global $user;
// Save the current user
$current_user = $user;
// Save user session
$current_session = drupal_save_session();
// From now on we don't want to save the session, since it would be unsafe
drupal_save_session(FALSE);
// We impersonate admin user
$user = user_load(1);
// Do wathever needs to be done.
// ...
// Now let's restore the triggering user and session.
$user = $current_user;
drupal_save_session($current_session);