<?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: User only/protected pages in WordPress</title>
	<atom:link href="http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/</link>
	<description>Website of Ben Huddleston - right now it's mainly a playground for testing Wordpress plugins.</description>
	<lastBuildDate>Sat, 20 Feb 2010 23:44:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Ben</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1708</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Sat, 20 Feb 2010 23:44:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1708</guid>
		<description>@Mukesh,

Yes, theoretically you could apply this same code to your index.php, single.php, category.php, and archive.php files in your template and force users to log in before viewing the posts.

@Exam Philippines 
I don&#039;t have a plugin for this but I do think that someone has come out with a plugin sometime in the past year that you can use that works similarly.</description>
		<content:encoded><![CDATA[<p>@Mukesh,</p>
<p>Yes, theoretically you could apply this same code to your index.php, single.php, category.php, and archive.php files in your template and force users to log in before viewing the posts.</p>
<p>@Exam Philippines<br />
I don&#8217;t have a plugin for this but I do think that someone has come out with a plugin sometime in the past year that you can use that works similarly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1550</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 28 Apr 2009 21:50:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1550</guid>
		<description>Hi Ben,

This is exactly what I have been looking for. The only problem is that the download is not available anymore. Could you please send me the file or the link to it?

Thank you very much,
James</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>This is exactly what I have been looking for. The only problem is that the download is not available anymore. Could you please send me the file or the link to it?</p>
<p>Thank you very much,<br />
James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Exam Philippines</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1552</link>
		<dc:creator>Exam Philippines</dc:creator>
		<pubDate>Sat, 04 Apr 2009 17:02:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1552</guid>
		<description>do you have a downloadable plugin for this? because i don&#039;t understand how to apply the codes. thanks!</description>
		<content:encoded><![CDATA[<p>do you have a downloadable plugin for this? because i don&#8217;t understand how to apply the codes. thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mukesh</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1551</link>
		<dc:creator>Mukesh</dc:creator>
		<pubDate>Fri, 20 Mar 2009 20:55:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1551</guid>
		<description>Hi, I&#039;m wondering if this same method will work for posts. The items here only mention page, but will this work for posts?
Thanks
Mukesh</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m wondering if this same method will work for posts. The items here only mention page, but will this work for posts?<br />
Thanks<br />
Mukesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Items of interest &#187; Blog Archive &#187; Bookmarks for December 3rd through December 4th</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1549</link>
		<dc:creator>Items of interest &#187; Blog Archive &#187; Bookmarks for December 3rd through December 4th</dc:creator>
		<pubDate>Thu, 04 Dec 2008 11:09:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1549</guid>
		<description>[...] User only/protected pages in WordPress &#124; Redwing Studio - [...]</description>
		<content:encoded><![CDATA[<p>[...] User only/protected pages in WordPress | Redwing Studio &#8211; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Create Protected pages (Members only) in Wordpress &#124; Wordpress</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1548</link>
		<dc:creator>Create Protected pages (Members only) in Wordpress &#124; Wordpress</dc:creator>
		<pubDate>Sun, 05 Oct 2008 11:22:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1548</guid>
		<description>[...] is â€“ If you have the password you can view. Here&#8217;s a protected page plugin template by redwing studio; condition is - If you are member of this blog, you can [...]</description>
		<content:encoded><![CDATA[<p>[...] is â€“ If you have the password you can view. Here&#8217;s a protected page plugin template by redwing studio; condition is &#8211; If you are member of this blog, you can [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rupert</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1547</link>
		<dc:creator>Rupert</dc:creator>
		<pubDate>Wed, 27 Aug 2008 23:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1547</guid>
		<description>Ben - it worked like a champ first time.  Thank you very much!

The only issue I ran into, and it has nothing to do with the script, was having it fit seemlessly into my site theme.  I was able to poke around and copy some stuff from the single.php and page files in the theme directory and manipulate the stylesheet some, but the result was still pretty amatureish.  I am using FTW 2.0 theme by flisterz...one of the best themes that I have seen on the WP platform; if anyone cares to take a stab at melding the protected.phps here with it to create a seemless page template, I would really appreciate it.

The ironic thing is, this might be a 5 minute job because I know I am pretty close, but not been able to speak programming, my abilities fall short of completing it.

I would post a link to my site, but I currently only have it on MAMPS on my IMAC.

Thanks very much again Ben.


Rupe</description>
		<content:encoded><![CDATA[<p>Ben &#8211; it worked like a champ first time.  Thank you very much!</p>
<p>The only issue I ran into, and it has nothing to do with the script, was having it fit seemlessly into my site theme.  I was able to poke around and copy some stuff from the single.php and page files in the theme directory and manipulate the stylesheet some, but the result was still pretty amatureish.  I am using FTW 2.0 theme by flisterz&#8230;one of the best themes that I have seen on the WP platform; if anyone cares to take a stab at melding the protected.phps here with it to create a seemless page template, I would really appreciate it.</p>
<p>The ironic thing is, this might be a 5 minute job because I know I am pretty close, but not been able to speak programming, my abilities fall short of completing it.</p>
<p>I would post a link to my site, but I currently only have it on MAMPS on my IMAC.</p>
<p>Thanks very much again Ben.</p>
<p>Rupe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1545</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Mon, 25 Aug 2008 05:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1545</guid>
		<description>Rupert,

It should be fairly simple to do what you want.  As in Ralphie&#039;s case, you&#039;ll need to create the capabilities using the Role Manager plugin.  For what you want to do, you&#039;ll need two capabilities.  You can name them whatever you want: &quot;View My Hidden Posts&quot; and &quot;View My Other Hidden Posts&quot; might be options.  To do that go to Users –&gt; Capabilities and type “View My Hidden Posts” minus the quotes into the New Capability Name input box and click Create Capability.  Now do the same for &quot;View My Other Hidden Posts&quot;.

Create two new roles or use existing roles and then just check off the new capability that is applicable for each role (either View My Hidden Posts or View My Other Hidden Posts).  For this example, let&#039;s call those we want to assign to Group 1 &quot;Studs&quot; and those in Group 2 &quot;Duds&quot;.

Then, you have a choice, you can incorporate this all into one page template or have two different page templates.  The simplest method is probably making two different page templates and assign whichever template is appropriate to the page.  Go grab a copy of this file here: http://www.redwingstudio.com/downloads/user-and-role-protected.phps (copy and paste it into your own blank php page and make two copies).

You can name the templates whatever you want.  In WordPress you name page templates by adding this at the top of the page:
&lt;code&gt;
&lt;?php /* Template Name: Hidden Page
*/ ?&gt;
&lt;/code&gt;

Just replace &quot;Hidden Page&quot; on my example template with whatever you want to name your template.  For the sake of my example, I&#039;ll call them &quot;Hidden Page for Studs&quot; and &quot;Hidden Page for Duds&quot;.

Now, you have your two copies of the hidden page template, but you need to make a change to our second one so we show the &quot;duds&quot; only the content that they should see. On the duds template, look for this line:
&lt;code&gt;if ( current_user_can(&#039;view_my_hidden_posts&#039;) ) {&lt;/code&gt;
replace it with
&lt;code&gt;if ( current_user_can(&#039;view_my_other_hidden_posts&#039;) ) {&lt;/code&gt;

Now, when you create a page that you want to be hidden, just choose the appropriate template from the template drop down.  If it&#039;s a page that only studs should see, choose the &quot;Hidden Page for Studs&quot; template.  If it&#039;s a page for duds, choose the &quot;Hidden Page for Duds&quot; template.

I&#039;m not sure how you&#039;re handling your navigation, but if you&#039;re creating links manually or have a separate section of the nav that you&#039;re creating specifically for these pages, you can set it up so that only people who are logged in can see those pages and they would only see pages they had access to be they a dud or a stud.  To do that, you&#039;ll just need to wrap a few if statements around your navigation:

First, wrap this around all the nav links that should be hidden or show depending on whether someone is logged in:

&lt;code&gt;
&lt;?php
if (is_user_logged_in()) {
// your navigation links will go here
}
?&gt;
&lt;/code&gt;

Then, you need to add the checks inside of the check for the user being logged in to show content for only the duds and studs:

&lt;code&gt;
&lt;?php
if (is_user_logged_in()) {
    if ( current_user_can(&#039;view_my_hidden_posts&#039;) ) {
      // stud links go here
    } else if ( current_user_can(&#039;view_my_other_hidden_posts&#039;) ) {
       // dud links go here
    }
}
?&gt;
&lt;/code&gt;

Hope the above helps. Let me know if you have any more questions.

Here are some links to some resources I found helpful when I was working with the capabilities and integrating them into the template:
http://codex.wordpress.org/Roles_and_Capabilities
http://boren.nu/archives/2005/12/01/whats-new-in-20-roles-and-capabilities/</description>
		<content:encoded><![CDATA[<p>Rupert,</p>
<p>It should be fairly simple to do what you want.  As in Ralphie&#8217;s case, you&#8217;ll need to create the capabilities using the Role Manager plugin.  For what you want to do, you&#8217;ll need two capabilities.  You can name them whatever you want: &#8220;View My Hidden Posts&#8221; and &#8220;View My Other Hidden Posts&#8221; might be options.  To do that go to Users –> Capabilities and type “View My Hidden Posts” minus the quotes into the New Capability Name input box and click Create Capability.  Now do the same for &#8220;View My Other Hidden Posts&#8221;.</p>
<p>Create two new roles or use existing roles and then just check off the new capability that is applicable for each role (either View My Hidden Posts or View My Other Hidden Posts).  For this example, let&#8217;s call those we want to assign to Group 1 &#8220;Studs&#8221; and those in Group 2 &#8220;Duds&#8221;.</p>
<p>Then, you have a choice, you can incorporate this all into one page template or have two different page templates.  The simplest method is probably making two different page templates and assign whichever template is appropriate to the page.  Go grab a copy of this file here: <a href="http://www.redwingstudio.com/downloads/user-and-role-protected.phps" rel="nofollow">http://www.redwingstudio.com/downloads/user-and-role-protected.phps</a> (copy and paste it into your own blank php page and make two copies).</p>
<p>You can name the templates whatever you want.  In WordPress you name page templates by adding this at the top of the page:<br />
<code><br />
< ?php /* Template Name: Hidden Page<br />
*/ ?><br />
</code></p>
<p>Just replace &#8220;Hidden Page&#8221; on my example template with whatever you want to name your template.  For the sake of my example, I&#8217;ll call them &#8220;Hidden Page for Studs&#8221; and &#8220;Hidden Page for Duds&#8221;.</p>
<p>Now, you have your two copies of the hidden page template, but you need to make a change to our second one so we show the &#8220;duds&#8221; only the content that they should see. On the duds template, look for this line:<br />
<code>if ( current_user_can('view_my_hidden_posts') ) {</code><br />
replace it with<br />
<code>if ( current_user_can('view_my_other_hidden_posts') ) {</code></p>
<p>Now, when you create a page that you want to be hidden, just choose the appropriate template from the template drop down.  If it&#8217;s a page that only studs should see, choose the &#8220;Hidden Page for Studs&#8221; template.  If it&#8217;s a page for duds, choose the &#8220;Hidden Page for Duds&#8221; template.</p>
<p>I&#8217;m not sure how you&#8217;re handling your navigation, but if you&#8217;re creating links manually or have a separate section of the nav that you&#8217;re creating specifically for these pages, you can set it up so that only people who are logged in can see those pages and they would only see pages they had access to be they a dud or a stud.  To do that, you&#8217;ll just need to wrap a few if statements around your navigation:</p>
<p>First, wrap this around all the nav links that should be hidden or show depending on whether someone is logged in:</p>
<p><code><br />
< ?php<br />
if (is_user_logged_in()) {<br />
// your navigation links will go here<br />
}<br />
?><br />
</code></p>
<p>Then, you need to add the checks inside of the check for the user being logged in to show content for only the duds and studs:</p>
<p><code><br />
< ?php<br />
if (is_user_logged_in()) {<br />
    if ( current_user_can('view_my_hidden_posts') ) {<br />
      // stud links go here<br />
    } else if ( current_user_can('view_my_other_hidden_posts') ) {<br />
       // dud links go here<br />
    }<br />
}<br />
?><br />
</code></p>
<p>Hope the above helps. Let me know if you have any more questions.</p>
<p>Here are some links to some resources I found helpful when I was working with the capabilities and integrating them into the template:<br />
<a href="http://codex.wordpress.org/Roles_and_Capabilities" rel="nofollow">http://codex.wordpress.org/Roles_and_Capabilities</a><br />
<a href="http://boren.nu/archives/2005/12/01/whats-new-in-20-roles-and-capabilities/" rel="nofollow">http://boren.nu/archives/2005/12/01/whats-new-in-20-roles-and-capabilities/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rupert</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-2/#comment-1546</link>
		<dc:creator>Rupert</dc:creator>
		<pubDate>Mon, 25 Aug 2008 03:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1546</guid>
		<description>Ben,
I was wondering if I could take Ralphie&#039;s concept a bit further.  What if I wanted to assign different folks registering at the site to different group with different access to different pages.

For ex.  Group 1 (role 1) can access protected pages 1 and 3
            Group 2 (role 2) can access protected pages 2 and 4.

How could I achieve that?  thanks.</description>
		<content:encoded><![CDATA[<p>Ben,<br />
I was wondering if I could take Ralphie&#8217;s concept a bit further.  What if I wanted to assign different folks registering at the site to different group with different access to different pages.</p>
<p>For ex.  Group 1 (role 1) can access protected pages 1 and 3<br />
            Group 2 (role 2) can access protected pages 2 and 4.</p>
<p>How could I achieve that?  thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Members only pages for Wordpress &#124; Karen Arnold Design, LLC</title>
		<link>http://www.ben-huddleston.com/coding/user-onlyprotected-pages-in-wordpress-2/comment-page-1/#comment-1542</link>
		<dc:creator>Members only pages for Wordpress &#124; Karen Arnold Design, LLC</dc:creator>
		<pubDate>Sun, 10 Aug 2008 04:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.redwingstudio.com/2007/04/05/user-onlyprotected-pages-in-wordpress-2/#comment-1542</guid>
		<description>[...] a thread on the Wordpress forums that explains how to make a page hidden using Role Manager and a template for hidden pages.  You will have to read it yourself, I am mostly posting it here so I can always find [...]</description>
		<content:encoded><![CDATA[<p>[...] a thread on the WordPress forums that explains how to make a page hidden using Role Manager and a template for hidden pages.  You will have to read it yourself, I am mostly posting it here so I can always find [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
