<?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>BraveNewCode Inc. &#187; Tutorials</title>
	<atom:link href="http://www.bravenewcode.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bravenewcode.com</link>
	<description>You dream it up, we code it to life.</description>
	<lastBuildDate>Thu, 22 Jul 2010 00:31:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>50 Excellent Icon Design Tutorials</title>
		<link>http://www.bravenewcode.com/2009/03/50-excellent-icon-design-tutorials/</link>
		<comments>http://www.bravenewcode.com/2009/03/50-excellent-icon-design-tutorials/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 21:39:42 +0000</pubDate>
		<dc:creator>Dale Mugford</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bravenewcode.com/?p=1315</guid>
		<description><![CDATA[A great resource for designers. But if you&#8217;re anythign like us, where the heck are you going to find the time to practice?
]]></description>
			<content:encoded><![CDATA[<p><a href="http://sixrevisions.com/graphics-design/50-excellent-icon-design-tutorials/">A great resource for designers</a>. But if you&#8217;re anythign like us, where the heck are you going to find the time to practice?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bravenewcode.com/2009/03/50-excellent-icon-design-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Show Content For Specific Users In WordPress Templates</title>
		<link>http://www.bravenewcode.com/2008/05/how-to-show-content-for-specific-users-in-wordpress-templates/</link>
		<comments>http://www.bravenewcode.com/2008/05/how-to-show-content-for-specific-users-in-wordpress-templates/#comments</comments>
		<pubDate>Fri, 02 May 2008 04:51:21 +0000</pubDate>
		<dc:creator>Dale Mugford</dc:creator>
				<category><![CDATA[Journal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[capabilities]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[custom templates]]></category>
		<category><![CDATA[roles]]></category>
		<category><![CDATA[Theme]]></category>

		<guid isPermaLink="false">http://www.bravenewcode.com/?p=114</guid>
		<description><![CDATA[One thing about building WordPress templates I haven&#8217;t seen a lot of documentation on is user-specific content. There are a few plugins out there that help with adjusting and assigning roles and capabilities, and there&#8217;s a good wiki document on the WordPress Codex site for defining the roles and capabilities that exist in WordPress, but [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bravenewcode.com/wp-content/uploads/groups-folder.png" alt="" title="groups-folder" width="128" height="128" class="alignleft size-medium wp-image-115" />One thing about building WordPress templates I haven&#8217;t seen a lot of documentation on is user-specific content. There are <a href="http://www.im-web-gefunden.de/wordpress-plugins/role-manager/">a few</a> <a href="http://asymptomatic.net/2005/12/31/2189/role-manager-plugin/">plugins</a> out there that help with adjusting and assigning roles and capabilities, and there&#8217;s a good <a href="http://codex.wordpress.org/Roles_and_Capabilities">wiki document</a> on the WordPress Codex site for defining the roles and capabilities that exist in WordPress, but not a lot about how to craft up some template codes to produce content for specific users.</p>
<p>Let&#8217;s say you have a little box on your sidebar you use to greet your subscribers (registered users), and also want to use it as a control box for your editors, authors, and contributors, while also as the administrator, have your own custom content there.</p>
<p>The first thing we&#8217;ll do is find out what levels our roles are at. On a default WordPress install of 2.5, the roles and the max. role number hierarchy are as follows:</p>
<p>Administrator: level 10<br />
Editor: Level 7<br />
Author: Level 4<br />
Contributor: Level 2<br />
Subscriber: Level 0<br />
<small>*all role levels also contain the capabilities of those below them</small></p>
<p>Now, there&#8217;s a little bit of a mess with regard to all the various capabilities assigned to each role, so if you want the long play version of what this is all about, visit the <a href="http://codex.wordpress.org/Roles_and_Capabilities">codex</a> for the nitty gritty.</p>
<p>So now, we know the number assigned to each role, but how do we identify who&#8217;s using the site and serve up dynamic content for them? WordPress <em>knows</em> who you are when you&#8217;re logged in, so we just have to ask it to show different content when it identifies users&#8217; roles.</p>
<p>It&#8217;s a good thing we can do this easily too, and we can add some DIVs around it, inside it, and style up our box any way we see fit. </p>
<p>To start, let&#8217;s create dynamic content showing for an administrator and subscriber, and something that will show by default to those not logged in:</p>
<p><code>&lt;?php<br />
  if (current_user_can(&#39;level_10&#39;)) : ?&gt;<br />
&lt;?php print &quot;control the world&quot;; ?&gt;<br />
&lt;?php elseif  (current_user_can('level_0')) : ?&gt;<br />
&lt;?php print &quot;read and comment only&quot;; ?&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;?php print &quot;you gotta log-in to see the goodies&quot;; ?&gt;<br />
&lt;?php endif; ?&gt;</code></p>
<p>With this code if an admin is logged in and viewing the page, &#8220;control the world&#8221; will be shown. If a subscriber is logged in, &#8220;read and comment only&#8221; will be shown to them instead. For users not logged in or registered, &#8220;you gotta log-in to see the goodies&#8221; will be shown.</p>
<p>Let&#8217;s go further, and add the other roles:</p>
<p><code>			  &lt;?php<br />
  if (current_user_can(&#39;level_10&#39;)) : ?&gt;<br />
&lt;?php print &quot;control the world&quot;; ?&gt;<br />
&lt;?php elseif  (current_user_can(&#39;level_7&#39;)) : ?&gt;<br />
&lt;?php print &quot;edit, write, publish, delete, read, comment&quot;; ?&gt;<br />
&lt;?php elseif  (current_user_can(&#39;level_4&#39;)) : ?&gt;<br />
&lt;?php print &quot;write, publish, delete, read, comment&quot;; ?&gt;<br />
&lt;?php elseif  (current_user_can(&#39;level_2&#39;)) : ?&gt;<br />
&lt;?php print &quot;write, read, comment&quot;; ?&gt;<br />
&lt;?php elseif  (current_user_can(&#39;level_0&#39;)) : ?&gt;<br />
&lt;?php print &quot;read and comment&quot;; ?&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;?php print &quot;you gotta log-in to see the goodies&quot;; ?&gt;<br />
&lt;?php endif; ?&gt;</code></p>
<p>Of course you can go to town here, and have entire loops, pages, and posts setup to be displayed dynamically to different roles when users are logged in. This method provides an excellent way to serve premium content on your WordPress site, dynamically. Of course a plugin like WP-Cache won&#8217;t work too well in this case because the dynamic content would get eaten up by the cache system.</p>
<p>There is a workaround there, though. With WP-Cache, you can force the cache to go and get another php file and include it outside of the cache:</p>
<p><code>&lt;!--mclude users.php--&gt;<br />
&lt;?php include_once(ABSPATH . &#39;&#39; . get_bloginfo(&#39;template_directory&#39;) . &#39;/users.php&#39;); ?&gt;<br />
&lt;!--/mclude--&gt;</code></p>
<p>In the above case, we put our dynamically-served role content into a separate php file called &#8216;users.php&#8217;, and dropped that in our active themes&#8217; directory. Then we put this code where we originally had it showing up before we activated WP-Cache. Abacadabra Batman: it&#8217;ll now stay dynamic.</p>
<p>Also, if you just want to show different content based on <a href="http://codex.wordpress.org/Function_Reference/is_user_logged_in">whether a user is logged in or not</a>, you can use this template tag anywhere you like:</p>
<p><code>&lt;?php if (is_user_logged_in()){ ... } ?&gt;</code></p>
<p>An example where different content is displayed:</p>
<p><code>&lt;?php  if (is_user_logged_in()){<br />
           echo &quot;Welcome, registered user!&quot;;<br />
         }<br />
         else {<br />
           echo &quot;Welcome, visitor!&quot;;<br />
           };<br />
?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bravenewcode.com/2008/05/how-to-show-content-for-specific-users-in-wordpress-templates/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
