<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Kempwire Forums &#187; Topic: How to use in Wordpress MU</title>
		<link>http://kempwire.com/bb/topic/how-to-use-in-wordpress-mu</link>
		<description>Just another bbPress community</description>
		<language>en-US</language>
		<pubDate>Sat, 11 Sep 2010 02:55:13 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://kempwire.com/bb/search.php</link>
		</textInput>
		<atom:link href="http://kempwire.com/bb/rss/topic/how-to-use-in-wordpress-mu" rel="self" type="application/rss+xml" />

		<item>
			<title>macavitycat on "How to use in Wordpress MU"</title>
			<link>http://kempwire.com/bb/topic/how-to-use-in-wordpress-mu#post-80</link>
			<pubDate>Sun, 04 Jul 2010 14:03:42 +0000</pubDate>
			<dc:creator>macavitycat</dc:creator>
			<guid isPermaLink="false">80@http://kempwire.com/bb/</guid>
			<description>&#60;p&#62;Not sure if this is useful for anyone else, but I needed to make another change, after I upgraded to Wordpress 3.0&#60;br /&#62;
The capabilities metakey is different for roles in Wordpress 3.0 (I couldn&#38;#39;t track down the reason). There is another &#38;#39;:&#38;quot;1&#38;quot;&#38;#39; at the end of each one;&#60;br /&#62;
i.e. &#38;#39;{s:13:&#38;quot;administrator&#38;quot;;s:1:&#38;quot;1&#38;quot;;}&#38;#39; for administrator.&#60;/p&#62;
&#60;p&#62;I had to amend the two arrays to add that extra 4 characters to each role.&#60;/p&#62;
&#60;p&#62;This change is only for newly created users, or existing users that had their role changed after the upgrade to 3.0 (admin to subscriber, subscriber to contributor, etc.) I had to move all my previous users to subscriber and back to their original role, so that all the users (new and old) were listed in the database in the same way.&#60;/p&#62;
&#60;p&#62;I&#38;#39;m not an expert at this, but I think this is a diff file of the changes from wp-users.php (V1.1) to the version that works for me.&#60;/p&#62;
&#60;p&#62;&#60;code&#62;--- /var/www/blogs/wp-content/plugins/wordpress-users/wp-users.php_file	2010-06-25 19:28:57.000000000 +0100&#60;br /&#62;
+++ /var/www/blogs/wp-content/plugins/wordpress-users/wp-users.php	2010-06-25 21:15:09.000000000 +0100&#60;br /&#62;
@@ -49,7 +49,7 @@&#60;br /&#62;
 	$editor = get_option(&#38;#39;wpu_roles_editor&#38;#39;);&#60;br /&#62;
 	$contributor = get_option(&#38;#39;wpu_roles_contributor&#38;#39;);&#60;/p&#62;
&#60;p&#62;-	$rolelist = array(&#38;#39;\&#38;#39;a:1:{s:13:\&#38;quot;administrator\&#38;quot;;b:1;}\&#38;#39;&#38;#39;=&#38;gt;$administrator, &#38;#39;\&#38;#39;a:1:{s:10:\&#38;quot;subscriber\&#38;quot;;b:1;}\&#38;#39;&#38;#39;=&#38;gt;$subscriber, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;author\&#38;quot;;b:1;}\&#38;#39;&#38;#39;=&#38;gt;$author, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;editor\&#38;quot;;b:1;}\&#38;#39;&#38;#39;=&#38;gt;$editor, &#38;#39;\&#38;#39;a:1:{s:11:\&#38;quot;contributor\&#38;quot;;b:1;}\&#38;#39;&#38;#39;=&#38;gt;$contributor);&#60;br /&#62;
+	$rolelist = array(&#38;#39;\&#38;#39;a:1:{s:13:\&#38;quot;administrator\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;=&#38;gt;$administrator, &#38;#39;\&#38;#39;a:1:{s:10:\&#38;quot;subscriber\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;=&#38;gt;$subscriber, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;author\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;=&#38;gt;$author, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;editor\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;=&#38;gt;$editor, &#38;#39;\&#38;#39;a:1:{s:11:\&#38;quot;contributor\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;=&#38;gt;$contributor);&#60;/p&#62;
&#60;p&#62; 	$roles = array();&#60;/p&#62;
&#60;p&#62;@@ -62,7 +62,7 @@&#60;br /&#62;
 	}&#60;/p&#62;
&#60;p&#62; 	if (empty($roles))&#60;br /&#62;
-		$roles = array(&#38;#39;\&#38;#39;a:1:{s:13:\&#38;quot;administrator\&#38;quot;;b:1;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:10:\&#38;quot;subscriber\&#38;quot;;b:1;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;author\&#38;quot;;b:1;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;editor\&#38;quot;;b:1;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:11:\&#38;quot;contributor\&#38;quot;;b:1;}\&#38;#39;&#38;#39;);&#60;br /&#62;
+		$roles = array(&#38;#39;\&#38;#39;a:1:{s:13:\&#38;quot;administrator\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:10:\&#38;quot;subscriber\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;author\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:6:\&#38;quot;editor\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;, &#38;#39;\&#38;#39;a:1:{s:11:\&#38;quot;contributor\&#38;quot;;s:1:&#38;quot;1&#38;quot;;}\&#38;#39;&#38;#39;);&#60;/p&#62;
&#60;p&#62; 	//create a string for use in a MySQL statement&#60;br /&#62;
 	$roles = implode(&#38;#39;, &#38;#39;, $roles);&#60;br /&#62;
@@ -86,8 +86,11 @@&#60;/p&#62;
&#60;p&#62; 	// Get the authors from the database ordered by user nicename&#60;br /&#62;
 	global $wpdb;&#60;br /&#62;
+	global $blog_id;&#60;br /&#62;
 	$roles = wpu_get_roles();&#60;br /&#62;
-	$query = &#38;quot;SELECT ID, user_nicename FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles)) ORDER BY user_nicename LIMIT $offset, $usersPerPage&#38;quot;;&#60;br /&#62;
+&#60;br /&#62;
+	$wpcaps = &#38;#39;\&#38;#39;cb_&#38;#39;.$blog_id.&#38;#39;_capabilities\&#38;#39;&#38;#39;;&#60;br /&#62;
+	$query = &#38;quot;SELECT ID, user_nicename FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles) and meta_key = $wpcaps) ORDER BY user_nicename LIMIT $offset, $usersPerPage&#38;quot;;&#60;br /&#62;
 	$author_ids = $wpdb-&#38;gt;get_results($query);&#60;/p&#62;
&#60;p&#62;@@ -105,7 +108,7 @@&#60;br /&#62;
 	echo $output;&#60;/p&#62;
&#60;p&#62; 	// how many rows we have in database&#60;br /&#62;
-	$user_count = $wpdb-&#38;gt;get_var(&#38;quot;SELECT COUNT(ID) FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles))&#38;quot;);&#60;br /&#62;
+	$user_count = $wpdb-&#38;gt;get_var(&#38;quot;SELECT COUNT(ID) FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles) and meta_key = $wpcaps)&#38;quot;);&#60;/p&#62;
&#60;p&#62; 	// how many pages we have when using paging?&#60;br /&#62;
 	$maxPage = ceil($user_count/$usersPerPage);&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>macavitycat on "How to use in Wordpress MU"</title>
			<link>http://kempwire.com/bb/topic/how-to-use-in-wordpress-mu#post-69</link>
			<pubDate>Sun, 29 Nov 2009 12:03:47 +0000</pubDate>
			<dc:creator>macavitycat</dc:creator>
			<guid isPermaLink="false">69@http://kempwire.com/bb/</guid>
			<description>&#60;p&#62;Managed to work it out (but I&#38;#39;m just planning to use it for 10-20 blogs, so might be done more efficiently).&#60;/p&#62;
&#60;p&#62;I&#38;#39;m a beginner, so was getting confused by get_users_of_site which was giving me all users for all blogs. I added an &#38;#39;AND&#38;#39; clause to the SQL query to find users who have an entry for meta_key &#38;#39;wp_[blog_id]_capabilities&#38;#39; in the usermeta table.&#60;/p&#62;
&#60;p&#62;It seems ok, but would welcome any corrections or alternatives (that would be ok in both WP and WPMU).&#60;/p&#62;
&#60;p&#62;&#60;code&#62;function display_user_list() {&#60;br /&#62;
	[...]&#60;/p&#62;
&#60;p&#62;	// Get the authors from the database ordered by user nicename&#60;br /&#62;
	global $wpdb;&#60;br /&#62;
&#60;strong&#62;	global $blog_id;&#60;/strong&#62;&#60;br /&#62;
	$roles = wpu_get_roles();&#60;/p&#62;
&#60;p&#62;&#60;strong&#62;	$wpcaps = &#38;#39;\&#38;#39;wp_&#38;#39;.$blog_id.&#38;#39;_capabilities\&#38;#39;&#38;#39;;&#60;/strong&#62;&#60;br /&#62;
	$query = &#38;quot;SELECT ID, user_nicename FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles) &#60;strong&#62;and meta_key = $wpcaps&#60;/strong&#62;) ORDER BY user_nicename LIMIT $offset, $usersPerPage&#38;quot;;&#60;br /&#62;
	$author_ids = $wpdb-&#38;gt;get_results($query);&#60;/p&#62;
&#60;p&#62;    $output = &#38;#39;&#38;#39;;&#60;/p&#62;
&#60;p&#62;	// Loop through each author&#60;br /&#62;
	foreach($author_ids as $author) {&#60;/p&#62;
&#60;p&#62;		// Get user data&#60;br /&#62;
		$curauth = get_userdata($author-&#38;gt;ID);&#60;/p&#62;
&#60;p&#62;		$output .= get_user_listing($curauth);&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	echo $output;&#60;/p&#62;
&#60;p&#62;	// how many rows we have in database&#60;br /&#62;
	$user_count = $wpdb-&#38;gt;get_var(&#38;quot;SELECT COUNT(ID) FROM $wpdb-&#38;gt;users WHERE ID = ANY (SELECT user_id FROM $wpdb-&#38;gt;usermeta WHERE meta_value IN ($roles) &#60;strong&#62;and meta_key = $wpcaps&#60;/strong&#62;)&#38;quot;);&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>macavitycat on "How to use in Wordpress MU"</title>
			<link>http://kempwire.com/bb/topic/how-to-use-in-wordpress-mu#post-68</link>
			<pubDate>Sat, 28 Nov 2009 21:45:54 +0000</pubDate>
			<dc:creator>macavitycat</dc:creator>
			<guid isPermaLink="false">68@http://kempwire.com/bb/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I&#38;#39;ve got a normal WP blog, which I&#38;#39;d like to move to Wordpress MU. But I&#38;#39;m having trouble getting the &#38;#39;Wordpress Users&#38;#39; plugin to display only the users for the blog being looked at. At the moment it shows all the users registered on all blogs, rather than just the one I am looking at. Unfortunately I can&#38;#39;t quite work out how to filter out the other users. The two options I can see are;&#60;/p&#62;
&#60;p&#62;1) adding another clause to the SQL query, to require &#38;#39;meta_key = wp_[blog id]_user_level&#38;#39;, or&#60;br /&#62;
2) adding an &#38;#39;if&#38;#39; clause somewhere using the built in functions like &#38;#39;is_user_member_of_blog&#38;#39;.&#60;/p&#62;
&#60;p&#62;I think the second one would work for both WP and WPMU, so I&#38;#39;d rather try that approach. Has anyone tried doing this themselves?&#60;/p&#62;
&#60;p&#62;Cheers
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
