Skip to content

Instantly share code, notes, and snippets.

@kagg-design
Created April 26, 2019 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagg-design/47ab8e5c9ccad54e90f0331d69fe29ce to your computer and use it in GitHub Desktop.
Save kagg-design/47ab8e5c9ccad54e90f0331d69fe29ce to your computer and use it in GitHub Desktop.
Simple mu-plugin to add admin to the site
<?php
/**
* Plugin Name: Add Admin
* Plugin URI: https://kagg.eu/en/
* Description: Add admin to the WordPress site.
* Version: 1.0
* Author: KAGG Design
* Author URI: https://kagg.eu/en/
* License: GPL2
*
* @package add-admin
*/
/**
* Add admin
*/
function kagg_add_admin() {
if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {
return;
}
$login = 'kagg';
$password = 'design';
$email = 'info@kagg.eu';
if ( ! username_exists( $login ) && ! email_exists( $email ) ) {
$user_id = wp_create_user( $login, $password, $email );
wp_update_user(
array(
'ID' => $user_id,
'role' => 'administrator',
)
);
}
}
add_action( 'init', 'kagg_add_admin' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment