Skip to content

Instantly share code, notes, and snippets.

View msjoker's full-sized avatar

Marcel CL msjoker

View GitHub Profile
@msjoker
msjoker / add-user-admin-wordpress-functions.php
Created December 12, 2017 08:56
Create user admin / Wordpress - Add in /theme/functions.php
function wp_add_admin_account(){
$user = 'newuser';
$pass = 'newpassword';
$email = 'xxx@mail.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','wp_add_admin_account');