Überspringen zu Hauptinhalt

How to Create an admin User with functions.php in WordPress

How To Create An Admin User With Functions.php In WordPress
StockSnap / Pixabay

Sometimes you don’t yet have proper database or backend access from your client but you need to got to the WordPress backend. Fortunately if you have some FTP credentials that work you can simply create a WordPress user by adding a few lines into the themes functions.php.

function wpb_admin_account(){
$user = 'enym';
$pass = '123456';
$email = 'info@enym.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' );
} }

Once you have logged in to your WordPress site, please edit the functions.php file and delete the code above. Deleting the code will not remove the user but you don’t need it anymore since it was already created by it’s first call.

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

An den Anfang scrollen