<?xml version="1.0" encoding="UTF-8"?><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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Member&#8217;s only area in WordPress</title>
	<atom:link href="http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress</link>
	<description></description>
	<lastBuildDate>Wed, 20 Apr 2011 17:38:58 -0500</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: premium wp themes</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-549</link>
		<dc:creator>premium wp themes</dc:creator>
		<pubDate>Sun, 28 Nov 2010 04:17:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-549</guid>
		<description>Just stopping by to praise you for the wonderful read. It was really worth my time reading this post. Waiting for more wonderful content soon! I added your feed in my reader!</description>
		<content:encoded><![CDATA[<p>Just stopping by to praise you for the wonderful read. It was really worth my time reading this post. Waiting for more wonderful content soon! I added your feed in my reader!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-106</link>
		<dc:creator>David</dc:creator>
		<pubDate>Fri, 27 Nov 2009 12:58:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-106</guid>
		<description>Thanks Ryan!</description>
		<content:encoded><![CDATA[<p>Thanks Ryan!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-105</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Thu, 26 Nov 2009 16:58:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-105</guid>
		<description>Hey David, you could do something like this:

if ((is_page(&#039;page-1&#039;) &#124;&#124; is_page(&#039;page-2&#039;) &#124;&#124; is_page(&#039;etc&#039;)) &amp;&amp; !is_user_logged_in()) {
     sidebarlogin();
} else {
     // show the page
}</description>
		<content:encoded><![CDATA[<p>Hey David, you could do something like this:</p>
<p>if ((is_page(&#8216;page-1&#8242;) || is_page(&#8216;page-2&#8242;) || is_page(&#8216;etc&#8217;)) &#038;&#038; !is_user_logged_in()) {<br />
     sidebarlogin();<br />
} else {<br />
     // show the page<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-104</link>
		<dc:creator>david</dc:creator>
		<pubDate>Thu, 26 Nov 2009 15:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-104</guid>
		<description>Hi Ryan - nice post here, seems very close to what I&#039;m looking for. One question (as I&#039;m not a php wiz): can you show an example of the extended if statement where you needed to protect many pages with different names? I&#039;m wondering how / where would you add those additional page name variables in that argument?</description>
		<content:encoded><![CDATA[<p>Hi Ryan &#8211; nice post here, seems very close to what I&#8217;m looking for. One question (as I&#8217;m not a php wiz): can you show an example of the extended if statement where you needed to protect many pages with different names? I&#8217;m wondering how / where would you add those additional page name variables in that argument?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-51</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Thu, 23 Jul 2009 18:28:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-51</guid>
		<description>Great points, thanks. It seems I was over complicating it a bit.  Yes this particular code is in the page.  Also to possibly avoid confusion to anyone else, I&#039;m placing the sidebarlogin() code inside the main column instead of the page content, not actually in the sidebar.

I like your idea of a special category.</description>
		<content:encoded><![CDATA[<p>Great points, thanks. It seems I was over complicating it a bit.  Yes this particular code is in the page.  Also to possibly avoid confusion to anyone else, I&#8217;m placing the sidebarlogin() code inside the main column instead of the page content, not actually in the sidebar.</p>
<p>I like your idea of a special category.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-50</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Thu, 23 Jul 2009 16:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-50</guid>
		<description>If you did want to use something similar to protect Posts, then you could make a special category called &quot;Protected&quot;, and then use the in_category() function inside the Loop, to check to see if the post is in that category.</description>
		<content:encoded><![CDATA[<p>If you did want to use something similar to protect Posts, then you could make a special category called &#8220;Protected&#8221;, and then use the in_category() function inside the Loop, to check to see if the post is in that category.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-49</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Thu, 23 Jul 2009 16:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-49</guid>
		<description>get_post_ancestors returns all parent IDs for a post, all the way up the tree to the root.

So having this structure:
GrandParent -&gt; Parent -&gt; Child -&gt; SubChild

A call to get_post_ancestors on the Subchild would return the ID&#039;s of all three above it. A call to it on the Child would return 2 ID&#039;s: the GP and the parent.

Also, I was assuming this was in page.php, so Posts don&#039;t factor into it. Posts don&#039;t have hierarchy anyway.

As for the check for unprotected pages, you&#039;re overthinking it. The only case where you show the sidebar login is if a) the page has an ancestor and thus protected and b) user isn&#039;t logged in. Every other case (user is logged in or page is unprotected) you show the page content.

So:
&lt;code&gt;
if (in_array(77,$ancestors) &amp;&amp; !is_user_logged_in()) {
sidebarlogin();
} else {
// show the page
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>get_post_ancestors returns all parent IDs for a post, all the way up the tree to the root.</p>
<p>So having this structure:<br />
GrandParent -&gt; Parent -&gt; Child -&gt; SubChild</p>
<p>A call to get_post_ancestors on the Subchild would return the ID&#8217;s of all three above it. A call to it on the Child would return 2 ID&#8217;s: the GP and the parent.</p>
<p>Also, I was assuming this was in page.php, so Posts don&#8217;t factor into it. Posts don&#8217;t have hierarchy anyway.</p>
<p>As for the check for unprotected pages, you&#8217;re overthinking it. The only case where you show the sidebar login is if a) the page has an ancestor and thus protected and b) user isn&#8217;t logged in. Every other case (user is logged in or page is unprotected) you show the page content.</p>
<p>So:<br />
<code><br />
if (in_array(77,$ancestors) &amp;&amp; !is_user_logged_in()) {<br />
sidebarlogin();<br />
} else {<br />
// show the page<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-48</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Thu, 23 Jul 2009 14:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-48</guid>
		<description>Otto, I&#039;ve never seen that function.  You&#039;d probably also have to check for the id of the parent also, unless calling get_post_ancestors() on the parent post returns the parents ID. 

You&#039;d also have to change the if statement to display the content of the page if the page is protected and they are logged in or if the page is not protected.

&lt;code&gt;
if ((in_array(77,$ancestors) &amp;&amp; is_user_logged_in()) &#124;&#124; !in_array(77,$ancestors)) {
	//display page
} else {
	sidebarlogin();
}
&lt;/code&gt;

It also looks like you&#039;d have to use something different for posts.  Thanks for bringing that function to my attention.</description>
		<content:encoded><![CDATA[<p>Otto, I&#8217;ve never seen that function.  You&#8217;d probably also have to check for the id of the parent also, unless calling get_post_ancestors() on the parent post returns the parents ID. </p>
<p>You&#8217;d also have to change the if statement to display the content of the page if the page is protected and they are logged in or if the page is not protected.</p>
<p><code><br />
if ((in_array(77,$ancestors) &#038;&#038; is_user_logged_in()) || !in_array(77,$ancestors)) {<br />
	//display page<br />
} else {<br />
	sidebarlogin();<br />
}<br />
</code></p>
<p>It also looks like you&#8217;d have to use something different for posts.  Thanks for bringing that function to my attention.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://www.creativegraymatter.com/blog/members-only-area-in-wordpress/comment-page-1#comment-47</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Thu, 23 Jul 2009 14:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.creativegraymatter.com/?p=249#comment-47</guid>
		<description>Instead of checking for a string in the URI, you could move your check down into the Loop, and check the post ancestors.

In the Loop, do something like this:
&lt;code&gt;
$ancestors = get_post_ancestors($post);
if (in_array(77,$ancestors)) echo &quot;77 is an ancestor of the post&quot;;
&lt;/code&gt;

Obviously, you wouldn&#039;t do the echo thing, but this will give you the complete parent history of a page in the form of an array of ID numbers. Check for the parent page ID number that you want, and act accordingly.</description>
		<content:encoded><![CDATA[<p>Instead of checking for a string in the URI, you could move your check down into the Loop, and check the post ancestors.</p>
<p>In the Loop, do something like this:<br />
<code><br />
$ancestors = get_post_ancestors($post);<br />
if (in_array(77,$ancestors)) echo "77 is an ancestor of the post";<br />
</code></p>
<p>Obviously, you wouldn&#8217;t do the echo thing, but this will give you the complete parent history of a page in the form of an array of ID numbers. Check for the parent page ID number that you want, and act accordingly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

