Skip to content

Instantly share code, notes, and snippets.

@erseco
Last active December 12, 2023 12:32
Show Gist options
  • Save erseco/79581e07ad191d5d48adea7a5e449f45 to your computer and use it in GitHub Desktop.
Save erseco/79581e07ad191d5d48adea7a5e449f45 to your computer and use it in GitHub Desktop.
sdfsd
/*
How to Use this Script in WordPress Multisite from the Browser Console
----------------------------------------------------------------------
1. Open the Site Creation Page: Log in to your WordPress Multisite network admin dashboard and navigate to the page where you add new sites.
2. Open the Browser Console: Right-click anywhere on the page and select "Inspect" or "Inspect Element", then go to the "Console" tab.
3. Paste the Script: Copy the entire script above and paste it into the console.
4. Execute the Script: Press Enter to run the script. It will start creating sites based on the user names defined in the users array.
5. Monitor the Progress: The script will automatically fill in the form and submit it for each user, with a 2-second delay between each submission to prevent server overload.
Remember to modify the users array and the admin email pattern (@example.org) as per your requirements before running the script.
*/
// Array of user names for the sites to be created
var users = ['user1', 'user2', 'user3'];
// Function to create sites for each user in the 'users' array
function createSites() {
users.forEach((user, index) => {
// Use setTimeout to delay execution for each user to prevent server overload
setTimeout(() => {
// Set the site's URL address based on the user name
document.getElementById('site-address').value = user;
// Set the site's title as 'Site of [user]'
document.getElementById('site-title').value = 'Site of ' + user;
// Set the admin email using a predefined pattern
document.getElementById('admin-email').value = user + '@example.org';
// Submit the form
document.getElementById('add-site').click();
}, index * 2000); // 2-second delay between each site creation
});
}
// Execute the createSites function
createSites();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment