Skip to content

Instantly share code, notes, and snippets.

@slattery
Forked from megclaypool/drupal.md
Last active October 11, 2022 14:44
Show Gist options
  • Save slattery/606cde3aa69222304a92eb8624d75787 to your computer and use it in GitHub Desktop.
Save slattery/606cde3aa69222304a92eb8624d75787 to your computer and use it in GitHub Desktop.
[I forgot my Password: Command Line Tools to the Rescue!] Note that these commands can also come in handy if your front-end is so messed up that you can't access the login screen...

Drush one-time login link for Drupal accounts

Holy crap, I never knew about this before, but this is awesome.

The command is drush uli

It's got options,

  • name for the username
  • uri to specify the url of the site (our weird setup requires us to specify the url of our site)

ex: drush uli --name=rootid --uri=http://midpen-openspace-d8.test

A window popped up that led straight to the user page, with its "reset password" fields! I'm using it on my local, so I'll need to redo if I pull the database from Pantheon, but I'm only doing this cause Jason's out of town so there aren't any changes to pull anyhow!

Using this command with Terminus to access a site on Pantheon

terminus drush <site_machine_name>.<env> -- uli --name=<username> --uri=https://dev-midpen-openspace-d8.pantheonsite.io

Note that a window doesn't pop open, but after a warning about the site being in Git mode and possibly adding the site to known hosts, the login url was output into the terminal!

Reset a WordPress user password using WP-CLI

If you know your username, you can just use:

wp user update USERNAME --user_pass="PASSWORD"

If you're not sure what your username is, you can get a list of all the accounts:

wp user list

Note that you can also use the USER_ID in place of the USERNAME, but you're a lot more likely to know your username than some random number assigned by the database...

Using this command with Terminus to access a site on Pantheon

terminus wp <site_machine_name>.<env> -- update USERNAME --user_pass="PASSWORD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment