diff --git a/masquerade_advanced/masquerade_advanced.module b/masquerade_advanced/masquerade_advanced.module
index b3e62bf..6ca153a 100644
--- a/masquerade_advanced/masquerade_advanced.module
+++ b/masquerade_advanced/masquerade_advanced.module
@@ -367,6 +367,30 @@ function masquerade_advanced_form_masquerade_block_form_alter(&$form, &$form_sta
 }
 
 /**
+ * Wrapper around user_load() to allow the loading of anonymous users.
+ *
+ * @param $username
+ *   The username of the user you wish to load (i.e. $user->name). To load the
+ *   anonymous user, pass the value of the 'anonymous' variable.
+ *
+ * @return object
+ *   A fully-loaded $user object upon successful user load or FALSE if user
+ *   cannot be loaded.
+ */
+function _masquerade_user_load($username) {
+  $account = FALSE;
+  if (!empty($username)) {
+    $anon = variable_get('anonymous', t('Anonymous'));
+    $account = user_load_by_name(($username == $anon ? '' : $username));
+    if (isset($account->uid) && empty($account->uid)) {
+      // Anonymous user should have a name.
+      $account->name = $anon;
+    }
+  }
+  return $account;
+}
+
+/**
  * Returns JS array for Masquerade autocomplete fields.
  *
  * Supports multiple entries separated by a comma.
