How to Add an Admin User in WordPress using FTP or How to add new admin in wordpress from function.php file
Its very easy to add admin from phpmyadmin but you can also add admin in wordpress from function.php file
Adding an Admin User in WordPress Using FTP
First thing you will need is an FTP client. If you are new to using FTP, then see our guide on how to use FTP to upload files in WordPress.
Once connected to your WordPress site, you need to locate your WordPress theme’s functions.php file. It would be at a location like this:
/yoursite.com/wp-content/themes/your-active-theme/functions.php
Right click on functions.php
file and then select download. Your FTP client will download the functions.php file to your computer.
Open the file you just downloaded on your computer using a plain text editor like Notepad or in dreamviver. Now you need to add this code at the bottom of the file.
####################
function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');
####################
Don’t forget to replace Username, Password, and email@domain.com with your own values.
Next, save the file and then upload it back to your website using the FTP client.
All done now you can login with these details into admin sectin of wordpress