<?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>Ladysign Dev Blog &#187; current_user</title>
	<atom:link href="http://www.ladysign-apps.com/blog/tag/current_user/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ladysign-apps.com/blog</link>
	<description>Girls can code.</description>
	<lastBuildDate>Mon, 12 Dec 2011 16:58:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wordpress: user restrictions tags</title>
		<link>http://www.ladysign-apps.com/blog/code/php/wordpress-user-restrictions-tags/</link>
		<comments>http://www.ladysign-apps.com/blog/code/php/wordpress-user-restrictions-tags/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 20:38:45 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[current_user]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[user levels]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress user restrictions]]></category>

		<guid isPermaLink="false">http://ladysign-apps.com/blog/?p=516</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 1 out of 5 stars<br />
I was working on a Wordpress blog, where I wanted to put some handy coding information, just for myself and my colleague&#038;[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/php/wordpress-user-restrictions-tags/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 1 out of 5 stars<br />
I was working on a Wordpress blog, where I wanted to put some handy coding information, just for myself and my colleague&#8217;s. Ofcourse I don&#8217;t want the whole world to read it and luckily Wordpress can set the visibility of posts to private.</p>
<p>That&#8217;s nice, but when you have only private posts in a menu category, this menu option won&#8217;t be shown on the page. So, what I did, is placing a first category post (with a date of early history), in front of it. And this page contains no secret information.<br />
Well yeah, ok, then the category option is visible in my menu, but when unknown blog readers click on this link, they will see a useless blogpost.</p>
<p>To solve this you need to script some php / wordpress function tags in your template.<br />
Let&#8217;s use the current_user object. It can retrieve the level of the user.<br />
The user level of an &#8216;Admin&#8217; is 10, the level of a &#8220;Contributor&#8221; 1.<br />
What I want is to show my &#8220;secret&#8221; menu, for everybody of userlevel 1 or above.<br />
And to display to everybody the &#8220;normal&#8221; menu.<br />
This is the code for in my sidebar.php:</p>
<pre class="brush: php; title: ;">
//my normal menu, excluding the (id of the) secret menu
	&lt;?php wp_list_categories('exclude=10'); ?&gt;
//my secret menu, excluding the (id of the) normal menu
	&lt;?php global $current_user;
		get_currentuserinfo();
		if($current_user-&gt;user_level &gt;= 1){
			wp_list_categories('exclude=11');
		}
	?&gt;
</pre>
<p>Now you just have to create some level 1 or higher, users!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/php/wordpress-user-restrictions-tags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

