Skip to content

Instantly share code, notes, and snippets.

@CabalTC
Last active January 4, 2020 19:55
Show Gist options
  • Save CabalTC/0d0c7a65b2d563f36a407b0a26043b6c to your computer and use it in GitHub Desktop.
Save CabalTC/0d0c7a65b2d563f36a407b0a26043b6c to your computer and use it in GitHub Desktop.
<?php
/*
Plugin: crear usuario administrador
Donate link: https://www.paypal.me/davidolier
Description: Crear usuario administrador en WordPress via PHP
Author: David Olier
Author URI: https://davidolier.com/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_action( 'init', 'do_admin_user' );
function do_admin_user() {
$usuario = 'administrador';
$password = 'contrasena';
$direccion_email = 'admin@tuweb.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $usuario, $password, $direccion_email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment