Skip to content

Instantly share code, notes, and snippets.

View johnennewdeeson's full-sized avatar

John Ennew johnennewdeeson

View GitHub Profile
@johnennewdeeson
johnennewdeeson / drupal_run_as.php
Last active October 25, 2015 07:28 — forked from angry-dan/drupal_run_as.php
Safely run a function in Drupal as another user.
<?php
function drupal_run_as($user, $func) {
global $user;
$original_user = $user;
$old_state = drupal_save_session();
drupal_save_session(FALSE);
$args = func_get_args();
$user = array_shift($args);