Multisite Feature Request – New Site Default Settings
-
I run a multisite installation with a setup script to create and populate new sites with default content and settings. Prior to AIOWPS 5.0.0 I stored a serialized array in a PHP script that saved the settings in aio_wp_security_configs for the new site wp_xx_options table. This stopped working with AIOWPS 5.0.0 causing a lockout on the new site admin pages. It’s probably a new setting needed to be stored in the serialized array that I haven’t had a chance to debug yet.
The requested feature is to enable for multisite installations a “new site default settings” that could be customized and saved so that all new sites created on a multisite installation would be automatically created with the desired AIOWPS settings.
-
We have fixed it in our development version. You can download it from https://drive.google.com/file/d/1vE93u9OrS_O2_WatIJoJcpBzomc8zu-s/view?usp=sharing in between. We are releasing it in next few minutes.
We have fixed the issue the user can’t login in the shared version. I have just created a task for the new site should be created with default option in our internal task management system and you will get it in next major release.
Thanks for you feature suggestion.
Apologies – my colleague pasted this in the wrong thread!
No problem! I posted the following that does most of what would be done in the feature request. If desired, I can post the PHP code used.
1. iterates through the all the subsites
2. Saves the desired ‘aio_wp_security_configs’ that I grabbed from one of the sites I setup with the desired settings
3. deletes the ‘aiowps_temp_configs’ option, which turns off the nag screen to apply the .htaccess rules since they were applied from the main site.`The results is all subsites with fully configured settings showing a good score on each dashboard.
Hi,
If you could post the PHP code that would be great, we are always open to suggestions to improve the product.
Sure! I have a custom plugin I wrote that is used to maintain the multisite installation I run. The plugin has utilities to perform various tasks such as copy files across domains, force updates to the various site settings etc. on a hosted Linux shared server.
For updates that require updates to individual site options table, the main program has a GUI to select the directory using descriptive names such as “2022-09-01 Push AIOWPS Settings Update (AIOWPS 5.0.x)”. Each directory contains the file update.php with unique PHP code for performing selected updates. Once selected, a Submit button is provided to execute. It then iterates through all the sites to perform the update and populates the screen with tabular data displaying the update status for each site. This is just a description on how it works so the context for the file below with the actual update code may be better understood.
The code below is in a file called update.php that resides in each GUI selectable directory. It can be called with the selected blog (number) and the main domain such as ‘mysite.com’ passes to it for execution. There was other stuff in the file I stripped out for update at the same time to keep this more manageable for display.
<?php /* * File update.php * File Version 2.3.8 (Multisite) * * This file is called to install an update using Crew Manager Master * It should work on all sites standalone and multi stite * *************************************************************** * 2022-09-01 Push AIOWPS Settings Update (AIOWPS 5.0.x) * This excludes master sites * Excludes stand alone sites * All the remotedb functions now work for pushing pages and posts * ********************************************************************* /*********************************************************** * function crew_manager_update ($selected_blog, $subdomain) * is called from Crew Manager Master to install the update * returns $status_array with update results for display * $selected blog is the blog number to be update * $subdomain is the domain root such as mysite.com that has the * selected blog as a subdomain to be updated ************************************************************/ function crew_manager_update ($selected_blog, $subdomain) { // set these variables for desired scope $force_exclude_master_site = true; // set to false to update main site too $production_domain = 'mysite.com'; // populate with the main site domain that has the subdomains such as xxx.mysite.com, yyy.mysite.com $test_domain = 'test.mysite.com'; // this is a special subdomain that is the root for the testing server that runs on the main domain and has additional subdomains $option_name = 'aio_wp_security_configs'; // this is the option that will be updated in the wp_xx_options table $deleted_option = 'aiowps_temp_configs'; // this gets deleted from wp_xx_options table global $wpdb; /**** store option as array variable used in site iteration loop ***/ $settings_array = get_option( $option_name, $default = false ); // get the options stored on main site /******* setup for multisite switching to selectected blog ***************/ $main_id = get_network()->site_id; // gets main site blog id if (is_multisite()) switch_to_blog($selected_blog); // operations done on the target blog if (is_multisite())$wpdb->set_blog_id( $selected_blog ); /*****************************************************/ /** execute below for all subsites and conditionally master site **/ /**** set $force_exclude_master_site near top of function to exclude *******/ ((($subdomain==$production_domain || $subdomain==$test_domain) && (int)$selected_blog!==1) || ($subdomain!==$production_domain && $subdomain!==$test_domain)) ? $exclude_master_site = true : $exclude_master_site = false; if ($exclude_master_site || !$force_exclude_master_site) { /** execute above all subsites, conditionally master site & stand alone sites **/ /******** begin update options settings ***********/ // update the options table with the decoded array $updated = update_option($option_name, $settings_array); // result is boolean if ($settings_array == get_option( $option_name, $default = false )) $updated = true; // check if site already has same value as master, if so it is good ($updated) ? $status_array[]=array('AIOWPS Settings Updated' => 'Yes') : $status_array[]=array('AIOWPS Settings Updated' => false); $deleted = delete_option($deleted_option); // deletes the temp initialization value stored ($deleted) ? $status_array[]=array('AIOWPS Temp Settings Deleted' => 'Yes') : $status_array[]=array('AIOWPS Temp Settings Deleted' => 'No Temp Settings'); } // end if ($exclude_master_site || !$force_exclude_master_site) /** end all subsites and conditionally master site **/ // set status below for master site if it is skipped if ($force_exclude_master_site && $selected_blog == 1 && is_multisite()) $status_array[]=array('Main Site' => 'Intentionally Skipped'); // completed with updates so switch back to main site if (is_multisite()) switch_to_blog($main_id); // back to the main site if (is_multisite())$wpdb->set_blog_id( $main_id ); return $status_array; // pass the status array back when done } // end function crew_manager_update()We have created a task to add a default setting on adding a new subsite created in the multisite network. You will get the resolution in a future AIOS plugin release.
Thank you for your suggestion. 🙂
The topic ‘Multisite Feature Request – New Site Default Settings’ is closed to new replies.