WordPress Mu hack to require users to log in to leave comment

I don’t know if anyone else will actually use this, but I was told by our IT security folks at work that I had to configure our WPMu installations so that folks could not comment anonymously.  “Why would you do that?” you may ask?  I work for a gov’t agency.  Logic doesn’t have to factor into their decisions, but with this one, I’m in agreement.  We have to have 100% attribution for anything in our systems.

I had to have it done ASAP, so I made a quick and dirty hack.  I have a php script that I use to touch/alter every blog in the WPMu database.  I don’t have it here, but it’s essentially grabbing all blogs, putting them into an array, then walking through each one.  I’m winging this off the top of my head, so the syntax isn’t perfect.

$blogs = wpdb->get_results(“SELECT blog_id from wp_blogs”, ARRAY_R);

foreach ($blogs as $details) {

$query=”UPDATE wp_” . $details['blog_id'] . “_options set option_value = 1 where option_name = ‘comment_registration’”;

}

You get the idea :)

Next, open up wp-admin/options-discussion.php, and at about line 49, you see the code that offers the blog admin the ability to toggle required registration. The checkbox says “Users must be registered and logged in to comment”. Comment out the whole section, and the admins can’t undo what you just did.

It’s quick, dirty, and goes completely against what I think is good coding, but I had to do it ten minutes ago. On Monday, I’ll start working on a plugin that fixes it. I hate editing core WPMu files for our needs….

This entry was posted in Development and tagged , , , . Bookmark the permalink.

2 Responses to WordPress Mu hack to require users to log in to leave comment

  1. Pingback: WordPress Preset Options Plugin

  2. Vapyblurbup says:

    I am always searching for recent informations in the world wide web about this theme. Thx.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>