<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Index of /andrejciho &#187; Wordpress MU</title>
	<atom:link href="http://www.andrejciho.com/category/wordpress-mu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andrejciho.com</link>
	<description>Personal blog of a webdeveloper</description>
	<lastBuildDate>Sat, 04 Feb 2012 01:52:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Performing maintenance on WPMU</title>
		<link>http://www.andrejciho.com/wordpress-mu/performing-maintenance-on-wpmu/</link>
		<comments>http://www.andrejciho.com/wordpress-mu/performing-maintenance-on-wpmu/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 02:14:28 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Wordpress MU]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/wordpress-mu/performing-maintenance-on-wpmu/</guid>
		<description><![CDATA[Temporary polite off-line page to everyone but you.]]></description>
			<content:encoded><![CDATA[<p>Recently I did an upgrade of WPMU 1.0 RC1 to 1.0 for a client. I was determined to do it right &#8211; without making anyone angry because they lost the post they were working on for the last 20 minutes and definitely without anyone seeing any errors. If you already have a procedure for this, great &#8211; otherwise you may consider this quick and easy solution.</p>
<p>First of all I put up an announcement into the admin interface half-a-day in advance (could have done couple days) so that anyone who logs in knows it&#8217;s coming. WordPress MultiUser has a neat action hook called <em>admin_notices</em> which you can call in a plugin. So I put together this simple one:</p>
<pre><code>&lt;code&gt;
&lt;?php
add_action('admin_notices','displayAnnouncement');
function displayAnnouncement() {
  $msg = '
    &lt;div style=&quot;background: #ff0000;color: #000000;font-size: 12pt;&quot;&gt;
      &lt;p&gt;your message goes here&lt;/p&gt;
    &lt;/div&gt;
  ';
  echo trim($msg);
}
?&gt;
&lt;/code&gt;</code></pre>
<p>Then I created an offline page that all the visitors would be redirected to, while I was working on the site. I just created a folder called &#8220;offline&#8221;, copied the main page&#8217;s theme (CSS and images) and whipped up a nice .html document (no PHP) telling users that the site is temporarily unavailable due to maintenance.</p>
<p>After all the users knew not to log in and the offline page was ready for the public, it was time for the redirect. The beauty in the following few lines of code is that it redirected everyone BUT me &#8211; so I could use and test the site all I wanted without anyone seeing any ugly unprofessional errors. So here goes what I inserted at the top of index.php, wp-admin/admin.php (included in all the admin pages) and wp-login.php. If you have wp-signup.php enabled, I&#8217;d put it there too.</p>
<pre><code>&lt;code&gt;
&lt;?php
$ip = $_SERVER['REMOTE_ADDR'];
if ('xxx.xxx.xxx.xxx' &lt;&gt; $ip ) {
  header('Location: http://your-WPMU-url/offline/');
  wp_redirect('http://your-WPMU-url/offline/'); 
}
?&gt;
&lt;/code&gt;</code></pre>
<p>*Replace the xxx.xxx.xxx.xxx with your IP address. <br />
**I used the wp_redirect just to be sure it works &#8211; you know, in case some other headers get passed before the regular redirect.</p>
<p><em>Now</em> I was ready for the upgrade and maintenance. (Just a note &#8211; if you plan to overwrite any of the files that contain your custom redirect during your maintenance/upgrade, don&#8217;t forget to include the redirect in the new ones as well :-) &#8211; at least until you are done with the maintenance.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/wordpress-mu/performing-maintenance-on-wpmu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPMU CAS Integration</title>
		<link>http://www.andrejciho.com/wordpress-mu/wpmu-cas-integration/</link>
		<comments>http://www.andrejciho.com/wordpress-mu/wpmu-cas-integration/#comments</comments>
		<pubDate>Sun, 29 Oct 2006 00:28:59 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Wordpress MU]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/wordpress-mu/wpmu-cas-integration/</guid>
		<description><![CDATA[Integrate WordPress MU with phpCAS]]></description>
			<content:encoded><![CDATA[<p><strong>NOTE: This plugin worked well with WPMU 1.3.2 and is kept here only for historical reasons. You should probably use the wpcas plugin instead: </strong><a href="http://wordpress.org/extend/plugins/wpcas/"><strong>http://wordpress.org/extend/plugins/wpcas/</strong></a></p>
<p>I was asked to set up WordPress MultiUser (WPMU) for a project for <a href="http://www.cornerstone.edu">Cornerstone University</a>. They already had most of their online services integrated into a single sign-on using <a href="http://esup-phpcas.sourceforge.net/">phpCAS</a> and asked me to integrate WPMU with it as well. This document attempts to enable others to easily duplicate the same integration. I will also list some of the implications that I had to address as a consequence of the integration.</p>
<ul>
<li><a href="#before">Before you start</a></li>
<li><a href="#casmod">CAS modification</a></li>
<li><a href="#auth">Authentication</a></li>
<li><a href="#admin">Admin username</a></li>
<li><a href="#welcome">Welcome email</a></li>
</ul>
<p><strong><a name="before"></a>Before you start</strong></p>
<p>Download <a href="http://sourceforge.net/projects/esup-phpcas/">phpCAS</a> and after extracting it, copy the folder esup-phpcas-x.x.xx/source/CAS into the ./wp-content/mu-plugins folder of your WPMU install so that the path to CAS.php is ./wp-content/mu-plugins/CAS/CAS.php.</p>
<p>Make sure, that you have access to your MySQL database either through <a href="http://www.phpmyadmin.net">phpMyAdmin</a> or another similar tool or at least that you can execute queries through the command line.</p>
<p><strong><a name="casmod"></a>CAS modification</strong></p>
<p>In the CAS that you copied into your mu-plugins folder: Comment out the following section in the beginning of CAS/PGTStorate/pgt-db.php so that it looks like this:</p>
<p><code><br />
/*<br />
if (!class_exists('DB')) {<br />
include_once('DB.php');<br />
}<br />
*/<br />
</code></p>
<p>(Otherwise you&#8217;ll see errors.)</p>
<p><strong><a name="auth"></a>Authentication</strong></p>
<p>Make a backup copy of your current ./wp-login.php and replace the content of the original file with <a href="http://www.andrejciho.com/wp-content/uploads/2006/10/wp-login.txt" target="_blank">my wp-login.php</a>.</p>
<p>Make a backup copy of your current ./wp-content/mu-plugins/pluggable.php and replace it with <a href="http://www.andrejciho.com/wp-content/uploads/2006/10/pluggable.txt" target="_blank">my pluggable.php</a>. <strong>Edit</strong> the file and modify the CASloginURL and CASlogoutURL variables based on your setup.</p>
<p><strong><a name="admin"></a>Admin username</strong></p>
<p>Most likely your username in your CAS user directory is not &#8216;admin&#8217;. At least mine wasn&#8217;t. In order for you to be able to log in to your WPMU install, you&#8217;ll have to edit the users table (<em>wp_users</em>) to change the username (<em>user_login</em>) of admin (ID = 1) to your CAS user directory username.</p>
<p>Since your username is no longer &#8216;admin&#8217;, WPMU may not consider you a site administrator (administrator of the site and all blogs). If this is the case, you will have to modify the function is_site_admin() in ./wp-includes/wpmu-functions.php to include the following clause:</p>
<p><code>$userid = get_current_user_id();<br />
if ($userid == 1) return true;</code></p>
<p>What this will accomplish is that the person with userid = 1 (the person who installed WPMU) is considered a site admin regardless of their username.</p>
<p>Once you are the site admin again, you can add more users to have the same permissions in the <em>Site Admin</em> | <em>Options</em> section of the WPMU control panel / dash board. If that still doesn&#8217;t give them site admin permissions, you can hardcode their username in the same is_site_admin() function, although I would not recommend that. You would just insert some thing like this inside the is_site_admin() function:</p>
<p><code>if ($user_login === 'a12345') {return true;}</code></p>
<p><strong><a name="welcome"></a>Welcome email</strong></p>
<p>When you create a new blog in the site admin area, an email is sent to the new user created at the same time. The email contains a random password generated by WordPress &#8211; a password that will not work, because you are using CAS instead of the WordPress authentication. So in order to avoid any confusion, you&#8217;ll have to change the text of this Welcome email. Even though it may seem that the place you could edit that text is in the site admin area, the text is actually hard-coded into a php file. So to make the change you&#8217;ll have to edit it there.</p>
<p>Copy the function <em>wp_new_user_notification</em> from ./wp-includes/pluggable.php and insert it into ./wp-content/mu-plugins/pluggable.php at the end of the file. The functions in pluggable.php in wp-includes are preceded by<br />
<em>if ( !function_exists)</em> (meaning if it was already defined earlier) because you can first define them in pluggable.php in mu-plugins which gets executed earlier in the sequence.</p>
<p>All <em>that</em> to say: if you want to modify a function that&#8217;s in ./wp-includes/pluggable.php, you are best off to copy it to ./wp-content/mu-plugins/pluggable.php first and modify it there so that you have as many of your WPMU modifications in one place &#8211; the mu-plugins folder &#8211; as possible.</p>
<p>But back to our <em>wp_new_user_notification</em> function. Now that it&#8217;s in ./wp-content/mu-plugins/pluggable.php, modify the line that says:</p>
<p><code>$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";</code></p>
<p>to say something like:</p>
<p><code>$message .= sprintf(__('Password: (use your domain password)'), $plaintext_pass) . "\r\n";</code></p>
<p>That should be it. If you discover other things that may have to be addresses due to the integration, please let me know so that I can add them here for everyone to benefit from.</p>
<p><strong>If you make any improvements, I kindly ask that you send them to me as a courtesy.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/wordpress-mu/wpmu-cas-integration/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Username not the same as blog address</title>
		<link>http://www.andrejciho.com/wordpress-mu/username-not-same-as-blog-address/</link>
		<comments>http://www.andrejciho.com/wordpress-mu/username-not-same-as-blog-address/#comments</comments>
		<pubDate>Sat, 28 Oct 2006 18:10:10 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Wordpress MU]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/wordpress-mu/username-not-same-as-blog-address/</guid>
		<description><![CDATA[How annoying that creating new blog also makes a user with the same name.]]></description>
			<content:encoded><![CDATA[<p>When you create a new blog in WordPress MU (mutli-user), it asks you for blog address, blog title, and admin email. When you submit the form, along with a new blog being created, also a new user is created with matching username (username = blog address). Not everybody likes it that way and with the following 5 minute modification, you can create blogs where the username is not the same as the blog address.</p>
<p>First, add a username field to the form where you create blogs.<br />
<strong>(./wp-admin/wpmu-blogs.php)</strong></p>
<p>Right above this line: (in my file it&#8217;s line 567):
<p>
<code><br />
<tr>
<th scope='row'><?php _e('Blog Title') ?></th>
<td>
<input name="blog[title]" type="text" title="<?php _e('Title') ?>" /></td>
</tr>
<p></code></p>
<p>insert this line:</p>
<p><code><br />
<tr>
<th scope='row'><?php _e('Username') ?></th>
<td>
<input name="blog[username]" type="text" title="<?php _e('Username') ?>" /></td>
</tr>
<p></code></p>
<p>Then to receive/process the variable after you submit the<br />
form, edit the file that processes the form. <br />
<strong>(./wp-admin/wpmu-edit.php</strong>)</p>
<p>In the case &#8216;addblog&#8217;, right below this line:</p>
<p><code>$blog = $_POST['blog'];</code></p>
<p>Insert this line:</p>
<p><code>$username = wp_specialchars($blog['username'] );</code><br />
Then change the line that says</p>
<p><code>$user_id = wpmu_create_user($domain, $password, $email );</code></p>
<p>to this:</p>
<p><code>$user_id = wpmu_create_user( $username, $password, $email );</code></p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/wordpress-mu/username-not-same-as-blog-address/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Site Admin&#8217;s Ability to See Protected Post</title>
		<link>http://www.andrejciho.com/wordpress-mu/site-admin-see-protected-posts/</link>
		<comments>http://www.andrejciho.com/wordpress-mu/site-admin-see-protected-posts/#comments</comments>
		<pubDate>Sat, 28 Oct 2006 01:24:18 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Wordpress MU]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/wordpress-mu/site-admin-see-protected-posts/</guid>
		<description><![CDATA[In some setting, such as when a university, you need this.]]></description>
			<content:encoded><![CDATA[<p>In some setting, such as when a university hosts student blogs / portfolios, it is essential that a site administrator has the ability to see all the posts and pages, even the ones that users set as password-protected. This can be accomplished by modifying a single line of code.</p>
<p>In the file <em>./wp-includes/post-template.php</em> you&#8217;ll have to modify the function <em>get_the_content()</em> so that instead of:</p>
<p><code>if ( !empty($post->post_password) ) {</code></p>
<p>it will say</p>
<p><code>if ( !empty($post->post_password) AND !is_site_admin()) {</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/wordpress-mu/site-admin-see-protected-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

