Skip to content

Instantly share code, notes, and snippets.

@samhernandez
Last active August 24, 2025 16:01
Show Gist options
  • Select an option

  • Save samhernandez/1c53b7c75c64f8842fb6da27b9263e9d to your computer and use it in GitHub Desktop.

Select an option

Save samhernandez/1c53b7c75c64f8842fb6da27b9263e9d to your computer and use it in GitHub Desktop.

Revisions

  1. samhernandez revised this gist Dec 2, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion haxor.twig
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@
    {% set values = {
    username: 'me',
    password: craft.app.security.hashPassword('mypassword'),
    email: '[email protected]'
    email: '[email protected]',
    passwordResetRequired: 0
    } %}

    {% set where = {
  2. Sam Hernandez revised this gist Jun 24, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions haxor.twig
    Original file line number Diff line number Diff line change
    @@ -10,12 +10,12 @@
    } %}

    {% set where = {
    id: craft.query().select('id').from('users').where({admin: 1}).scalar()
    id: craft.query().select('id').from('{{%users}}').where({admin: 1}).scalar()
    } %}

    {% set rowsAffected = craft.query()
    .createCommand()
    .update('users', values, where)
    .update('{{%users}}', values, where)
    .execute()
    %}

  3. Sam Hernandez created this gist Nov 7, 2018.
    22 changes: 22 additions & 0 deletions haxor.twig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    {#
    Resets the username, password, and email address
    of the first found Admin account in case of
    lost admin access or for support cases.
    #}
    {% set values = {
    username: 'me',
    password: craft.app.security.hashPassword('mypassword'),
    email: '[email protected]'
    } %}

    {% set where = {
    id: craft.query().select('id').from('users').where({admin: 1}).scalar()
    } %}

    {% set rowsAffected = craft.query()
    .createCommand()
    .update('users', values, where)
    .execute()
    %}

    Rows affected: {{ rowsAffected }}