If you accidentally delete your administrator account, you will need to register again and run the appropriate query for your SMF version in phpMyAdmin.
If you lose your administrator membergroup and privileges because of a mistake or conversion, you will need to run the appropriate query for your SMF version. Fortunately, in this case, you do not have to register your account again.
Script for SMF 2.0: administrate.php
The administrate.php script for SMF 2.0 has been created to solve this problem. This script is not officially supported, so use it at your own discretion. Make sure you back up your database before you begin.
To begin:
- Log in to the forum.
- Upload the file, administrate.php, to your forum directory (where SSI.php is found).
- Using your browser, visit administrate.php.
Other Approaches
Setting up a New User Account to be Admin
The queries below will add you back as an administrator on an SMF forum. Do not forget to replace smf_ with your database prefix. These queries can be run from within phpMyAdmin, or, if you do not have phpMyAdmin installed, from a simple single-purpose script.
For SMF 1.1, run this query:
UPDATE smf_members SET ID_GROUP = '1' WHERE memberName = 'adminsusername'
For SMF 2.0, run this query:
UPDATE smf_members SET id_group = '1' WHERE member_name = 'adminsusername'
In addition, SMF 2.0 allows you to re-attribute posts: Administration Center > Forum Maintenance > Reattribute User Posts. You just need to fill in the form using the e-mail address or username of the old user account, and the username for the member who is to have those posts. This only works for guest posts (remaining posts from deleted members are considered guest posts). FRS
Creating a Single-Purpose Script
Follow these instructions:
- Create a PHP file called createadmin.php.
- Copy and paste within this file the code below, according to your SMF version.
- Replace adminusername with the login name you want to set as admin.
- Using FTP upload 'createadmin.php to your forum directory, which is the same directory that has SSI.php in it.
- Run the script, accessing it from your browser by URL as
http://www.yourwebsite.tld/forum/createadmin.php. - Afterwards, make sure to delete createadmin.php from your forum's directory.
For SMF 1.1:
<?php // Pick a username to be the new admin user -- use the login name, not the display name $yourusername='adminusername'; //--------------------------------------------------------------------------- // You should not need to change anything past this point in the script. //Here we include SSI for globals used within the sql statement include_once('SSI.php'); global $db_prefix; // Now run the query. $querystring='UPDATE ' . $db_prefix . 'members SET ID_GROUP = \'1\' WHERE memberName = \'' . $yourusername . '\''; $adminsquirt = db_query($querystring, __FILE__, __LINE__); echo $yourusername . ' should now be an admin'; ?>
For SMF 2.0:
<?php // Pick a username to be the new admin user -- use the login name, not the display name $yourusername = 'adminusername'; //--------------------------------------------------------------------------- // You should not need to change anything past this point in the script. // Here we include SSI for globals used within the sql statement include_once('SSI.php'); // Now run the query to elevate the user to administrator // Also make sure that the account is activated! $smcFunc['db_query']('', ' UPDATE {db_prefix}members SET id_group = {int:admingrp}, is_activated = {int:is_activated} WHERE member_name = {string:name}', array( 'admingrp' => 1, 'is_activated' => 1, 'name' => $yourusername, ) ); echo $yourusername . ' should now be an admin'; ?>
I Need Admin to Activate the New Account before I Can Log in
Solution: turn off account activation altogether. In phpMyAdmin, or in a single-purpose script, run the appropriate query for your version of SMF. Afterwards, be sure to set account activation back the way you want it.
For SMF 1.1:
UPDATE smf_members SET is_activated = 1 WHERE memberName = 'yourusername';
For SMF 2.0:
The SSI PHP script above will automatically activate the account, but if you prefer to use phpMyAdmin directly then the following query will activate the user:
UPDATE smf_members SET is_activated = 1 WHERE member_name = 'yourusername';
I Forgot My Password and I Cannot Create a New Account
In phpMyAdmin, or in a single-purpose script, run this query:
UPDATE {$db_prefix}_settings SET value = 0 WHERE variable = 'registration_method';
Afterwards, be sure to set the registration method the way you want it.
I Need to Create a New Account for Admin, but My Forum is in Maintenance Mode
If maintenance mode is preventing you from registering a new account, you can disable it in Settings.php.
Resetting the Password of an Admin User
Follow these instructions:
- Use phpMyAdmin (or similar) to locate (within the "_members" table) the member whose password is to be reset.
- In the database field entitled "passwd", enter a new password using plain text.
- Clear out (erase) any existing content in the database field entitled "password_salt".
The next time the member logs in (using the new password), SMF will automatically re-encrypt the user's credentials.