Skip to content

Instantly share code, notes, and snippets.

@vaughanm
Created December 2, 2015 21:51
Show Gist options
  • Save vaughanm/f3b84072bb927eab8311 to your computer and use it in GitHub Desktop.
Save vaughanm/f3b84072bb927eab8311 to your computer and use it in GitHub Desktop.
Sets comments to registered users only across entire network (multisite)
function wpmudev_change_comment_settings() {
global $wpdb;
$blog_ids = wp_get_sites();
foreach($blog_ids as $blog) {
switch_to_blog($blog['blog_id']);
$wpdb->query("UPDATE {$wpdb->prefix}options SET option_value = 1 WHERE option_name = 'comment_registration'");
restore_current_blog();
}
}
add_action('admin_init', 'wpmudev_change_comment_settings');
@vaughanm
Copy link
Author

vaughanm commented Dec 2, 2015

This mu-plugin is to be used to set comments to be only registered users only across the entire multisite network in 1 go.

Add the mu-plugin, then visit the dashboard on your multisite.

Once done, remove the mu-plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment