Create a new admin user programmatically - If you have ftp access you can create an admin user for yourself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Create a new admin user programmatically | |
Plugin URI: https://www.damiencarbery.com/2022/11/create-a-new-admin-user-programmatically/ | |
Description: If you have ftp access you can create an admin user for yourself. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
// Code originally from https://wphub.me/create-new-wordpress-admin-user-programmatically/ | |
function wpb_admin_account(){ | |
$user = 'damiencarbery'; // Change these values before you upload this file. | |
$pass = 'Hb57%b9nc$4W'; // I've never used this password :-) | |
$email = 'damien@damiencarbery.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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment