Skip to content

Instantly share code, notes, and snippets.

@iamstoick
Last active September 8, 2017 06:52
Show Gist options
  • Save iamstoick/4150b2b60daaa6af412e906674ac992e to your computer and use it in GitHub Desktop.
Save iamstoick/4150b2b60daaa6af412e906674ac992e to your computer and use it in GitHub Desktop.
A most inappropriate way to gain access to Drupal administration.

Scenario:

You need to update some configuration but you dont have
username and password,
no access in the database as well,
Drush is not an option as well,
MTA (mail) is not installed in the server,
BUT you have access to the code.

Luckily there is a trick to gain an access with the above restrictions. In the code particularly in template.php of active theme just put the below command and refresh the page.

NOTE: You may need to refresh several times to see the admin menu.

global $user;
$user = user_load(1);

WARNING: Don't do this in production as you are going to grant all visitors an administrator access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment