Create an admin user programmatically in WordPress

0

–> Create an admin user programmatically in WordPress

add_action('init', 'add_user');
function add_user(){

$username = 'username123';
$password = 'pasword123';
$email = '[email protected]';

$user_id = wp_create_user($username, $password, $email);

$user = get_user_by('id', $user_id);

$user->remove_role('subscriber');

$user->add_role('administrator');
}

Related Posts

Leave a Reply

twenty + 16 =

Text Widget

Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue. Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod.

Recent Works

Recent Comments