Community Support Forums — WordPress® ( Users Helping Users ) — 2011-11-02T09:44:33-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=14651 2011-11-02T09:44:33-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=50783#p50783 <![CDATA[Re: Protect Custom Post Types]]>

Statistics: Posted by dhempy — November 2nd, 2011, 9:44 am


]]>
2011-11-01T19:39:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=50739#p50739 <![CDATA[Re: Protect Custom Post Types]]>
( click to enlarge )
SNAG-0102.png

Statistics: Posted by Jason Caldwell — November 1st, 2011, 7:39 pm


]]>
2011-10-27T13:44:17-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=48989#p48989 <![CDATA[Re: Protect Custom Post Types]]>
-dave

Statistics: Posted by dhempy — October 27th, 2011, 1:44 pm


]]>
2011-10-26T16:36:39-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=48897#p48897 <![CDATA[Re: Protect Custom Post Types]]> Thanks for the follow-up.

Right, Post Level Restrictions allow you to protect "all" Posts, or specific Post IDs, but s2Member does not have a built-in way to protect "all" Posts of a specific type yet.

You CAN protect specific Post IDs with s2Member using Post Level Restrictions, even if they are Custom Post Types (that's fine to do that); but protecting "all" means that you're protecting "all" Posts (of any kind), regardless of Post Type. So this is where you're having a problem.

In your case, here is what I would do...

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php ( these are MUST USE plugins, that's what you want )
Reference article: http://codex.wordpress.org/Must_Use_Plugins
Code:
<?php
add_action 
("wp", "my_custom_s2_security_gate");
function my_custom_s2_security_gate ()
    {
        if (!is_admin() && is_singular ("my_custom_post_type") && !current_user_can ("access_s2member_level1"))
            /* This protects "all" Posts of Post Type: `my_custom_post_type`. See: <http://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_Single_Post_or_Attachment>. */
            wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . exit ();
    }
?>

Reference articles:
http://codex.wordpress.org/Conditional_ ... Attachment
http://devpress.com/blog/conditional-ch ... ost-types/

Statistics: Posted by Jason Caldwell — October 26th, 2011, 4:36 pm


]]>
2011-10-26T14:34:27-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=48881#p48881 <![CDATA[Re: Protect Custom Post Types]]>
Jason Caldwell wrote:
OK, just to clarify for the benefit of other readers. s2Member DOES support Custom Post Types. You can protect Custom Post Types with s2Member's Post Level Access Restrictions in your Dashboard, under: s2Member -> Restriction Options -> Post Level Access Restrictions.


Jason - Can you expand on this? I don't see any way to protect a CPT on that page.

Do you mean that an individual post (e.g. id=124) can be protected, even if it is of a CPT? That's not what I'm looking for. I want *all* posts of a given CPT to be protected. Is there any way to do that?

Thanks, as always, for your great support, Jason!
-dave

Statistics: Posted by dhempy — October 26th, 2011, 2:34 pm


]]>
2011-10-14T13:51:16-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=46882#p46882 <![CDATA[Re: Protect Custom Post Types]]> everything of a given CPT.

If I don't trust my client to tag or categorize each new "Lab" post to ensure it is protected, I certainly would not expect them to add each post ID to a list of protected posts on this page.

I hope I'm missing something and that you'll point me in the right direction. I really want to tell my users to simply create new Labs, and they will be protected without any more work from them. (And to be confident there's no way for them to accidentally screw it up!) I've pretty well reached that point by adding custom code to templates, but I'd readily abandon that if there was a turn-key solution to protecting an entire CPT.

Thanks,
-dave

Statistics: Posted by dhempy — October 14th, 2011, 1:51 pm


]]>
2011-10-12T16:00:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=46714#p46714 <![CDATA[Re: Protect Custom Post Types]]>
No, I need to protect the entire CPT, without regard to taxonomies.

Thanks,
-dave

Statistics: Posted by dhempy — October 12th, 2011, 4:00 pm


]]>
2011-10-11T19:11:23-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=46634#p46634 <![CDATA[Re: Protect Custom Post Types]]> Thanks for the heads-up on this thread.

OK, just to clarify for the benefit of other readers. s2Member DOES support Custom Post Types. You can protect Custom Post Types with s2Member's Post Level Access Restrictions in your Dashboard, under: s2Member -> Restriction Options -> Post Level Access Restrictions.

That being said, it is true there is no way to protect Custom Taxonomies ( i.e. Custom Categories that contain Custom Post Types ), other than with URI Restrictions; and we will try to improve upon this in a future release, definitely. @dhempy Just to confirm, this IS what you're referring to, correct?

Statistics: Posted by Jason Caldwell — October 11th, 2011, 7:11 pm


]]>
2011-10-07T00:39:55-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=45010#p45010 <![CDATA[Re: Protect Custom Post Types]]>

Thanks for the suggestion to include custom post types in the access restrictions!

Statistics: Posted by Cristián Lávaque — October 7th, 2011, 12:39 am


]]>
2011-10-06T14:50:31-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=44985#p44985 <![CDATA[Re: Protect Custom Post Types]]>
I tried using URI restrictions, but that had a problem: I DO want the whole world to see archive-labs.php, listing all the Labs with their teaser text, but you must be a member to actually open the Labs. I could probably work around the URL issue for the archive page, but the ultimately it would still not protect the labs when accessed other ways. (feeds, post ID, etc.)

I used the approach described in the video, but a little differently. My site uses a single-labs.php template. I added the following code to the top of that template:

Code:
<?php
   if (! current_user_can("access_s2member_level2")) {
      wp_redirect( home_url('/sign-up/') );
      exit();
   }
?>


This meets all my needs. I may change that to custom capabilities after I get some other things nailed down.

Having said that, missing Custom Post Types in s2member's restrictions seems like a big oversight to me. I hope you add that feature in the future.

Keep up the good work, guys!
-dave

Statistics: Posted by dhempy — October 6th, 2011, 2:50 pm


]]>
2011-08-23T23:50:25-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=32750#p32750 <![CDATA[Re: Protect Custom Post Types]]>

Another thing you may want to try is the customization Jason explains in the 2nd segment of the Custom Capabilities video, only instead of checking for a tag or category in the condition, it'd be a custom post type (if that's possible). http://youtu.be/h7zBH938VbA

I hope that helps!

Statistics: Posted by Cristián Lávaque — August 23rd, 2011, 11:50 pm


]]>
2011-08-23T21:37:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=32731#p32731 <![CDATA[Re: Protect Custom Post Types]]>
For others reading this post, I've implemented s2member protection on all instances of a specific custom post type by using URI restrictions in conjuction with CPT archive permalinks. I set up archives for custom post types, and then just used the slug of the CPT archive to protect any posts using that slug. So anything at example.com/custom-post-type-name/post-name would be protected because /custom-post-name/ is in the URI restrictions in s2membet options. Seems to work great and I don't have to worry about client deselecting a category.

Statistics: Posted by dev9833 — August 23rd, 2011, 9:37 pm


]]>
2011-08-23T20:12:52-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=32722#p32722 <![CDATA[Re: Protect Custom Post Types]]> Hmm, I'll see what we can do about this in a future release.

That being said, s2Member's Post Level Access Protection is fully compatible with Custom Post Types. So if you want to, you can protect individual Posts this way, by ID, and it's OK if they're Custom Post Types.

The Category and/or Tag-based Restrictions are probably better though, so I think you're already on the right track. As far as the nesting goes, s2Member associates it's protection based on Category ID, and that does not change if/when the nesting order changes. So just make sure that you protect all any sub-categories inside the main category as well. That way if they're moved around and/or re-ordered, the client won't lose the protections applied by s2Member.

Again, I'll see what we can do to improve on this in a future release. We have some more work to do in this area already, related to bbPress Forum Topics, so perhaps we can look at this again at that time.

Statistics: Posted by Jason Caldwell — August 23rd, 2011, 8:12 pm


]]>
2011-08-23T00:09:59-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14651&p=32659#p32659 <![CDATA[Protect Custom Post Types]]>
Seems like something that would be a good core integration into the plugin anyway. If I'm missing something please let me know! Cheers.

Thanks in advance.

Statistics: Posted by dev9833 — August 23rd, 2011, 12:09 am


]]>