This WordPress function can be used to register a new admin user in the WordPress database:
function register_new_admin_user($username, $password, $email) {$userdata = array('user_login' => $username,'user_pass' => $password,'user_email' => $email,'role' => 'administrator');$user_id = wp_insert_user($userdata);if (!is_wp_error($user_id)) {$user = get_user_by('id', $user_id);$user->set_role('administrator');return $user_id;}return false;}register_new_admin_user('newadmin', 'password123', 'admin@example.com');
Make sure to replace 'newadmin', 'password123', and 'admin@example.com' with the desired values for the new admin user.
Please note that it's essential to use this function responsibly and securely. It's recommended to only use it for legitimate purposes and ensure that appropriate security measures are in place, such as validating user input and handling passwords securely.