Tell us what you are trying to do?
I want to create a CPT called COURSES. Each course with have SECTIONS. Each Section will have VIDEOS.
Obviously this will be a video training course, broken down into sections, with each section having multiple videos.
I'm using RESTRICT CONTENT PRO to manage the memberships for each COURSE.
How would I make sure that a member of COURSE A can only see Videos attached to the Section that is attached to the Course A?
Is there any documentation that you are following?
No.
Is there a similar example that we can see?
Not that I am aware.
What is the link to your site?
hidden link
Hello, I'm not really familiar with the Restrict Content Pro plugin. It looks pretty powerful, but it doesn't have any direct integration with Toolset. It seems from your comments that you need to set up several custom post types like Courses, Sections, and possibly even Videos, all linked in some type of post relationship hierarchy where Courses is a parent of Sections and Sections is possibly a parent of Videos. You'd like to limit access to individual Video posts based on the access granted to the ancestor Course post.
I'm not aware of an easy way to tie RCP's access rights to Toolset's post types and post relationships, as there is no direct integration between Toolset and the Restrict Content Pro plugin. If they offer a PHP API you can use to restrict post access programmatically, I can show you how to use the Toolset Post Relationships API to determine a Video post's parent Section or grandparent Course, then you might be able to use their API to determine whether or not the current User has access to that grandparent Course and allow or block their access.
If you need any information from me to help facilitate a discussion with that plugin's support team, please let me know. Here's what I would ask:
1. Is it possible to programmatically restrict access to a specific post using a PHP API filter or hook? For example, if a specific User tries to access a post with ID 12345, is there an API available that allows me to block access to that post for the current User, programmatically? If so, can you provide a code snippet demonstrating that process with your API?
2. Is there a PHP API available to help determine whether or not the current User has access to a given post by ID? If so, can you provide a code snippet?
If you can get that information from their support team, I might be able to help guide you to setting up some custom code that tests access rights to a related ancestor post, then allows or blocks access to that descendent post programmatically.
I have filed a support ticket with those exact questions. Perfection kind sir...
Great, I'll stand by for your update.
Alright... So I got a fluff answer... Basically a search for yourself and find answer...
Hi,
on 1 and 2: yes. Please check the Helpcenter for information on specific Restrict Content Pro functions, actions and hooks, the Restrict Content Pro API and more: hidden link
Code snippets are provided for a lot of these.
Let us know if you have any additional inquiries, or need further assistance, thanks!
I'm uncertain what to do from here.
It might require more hands on work, but I wonder if I might require each video to manually have the RESTRICT CONTENT PRO membership be applied. Every post type can have membership levels applied to it in the WordPress editor. So maybe I could require the user to apply the membership level(s) to it. For instance... user creates course A and it has videos How to ride a bike, how to ride a skateboard and how to ride rollerblades. Then creates course B and wants the video how to ride a skateboard to be included, they can actually edit the video and include the membership level for COURSE A and B on that video. Does that make sense? Then it wouldn't be PROGRAMMATICALLY handled, but manually. It would require more work on the user end, but it might just be the nature of the beast.
I think this knowledge base might answer 2... hidden link
Alright... So I got a fluff answer... Basically a search for yourself and find answer......I'm uncertain what to do from here.
I see their response also says "Let us know if you have any additional inquiries, or need further assistance, thanks!", so I would follow up and ask for a more specific answer. I would say:
I see a filter rcp_is_restricted_content in the documentation that seems to be what we need, but no example code snippet: https://help.ithemes.com/hc/en-us/articles/360052997913-rcp-is-restricted-content
Is this the correct filter to use to programmatically restrict access to a post with ID 12345, like so?
function tssupp_filter_rcp_access( $is_restricted, $post_id ) {
// restrict access to post ID 12345 programmatically
if( $post_id == 12345){
return true;
}else{
return false;
}
}
add_filter( 'rcp_is_restricted_content', 'tssupp_filter_rcp_access', 10, 2 );
If not, please provide a working example that will programmatically restrict access to post 12345 using your PHP APIs.
It might require more hands on work, but I wonder if I might require each video to manually have the RESTRICT CONTENT PRO membership be applied.
That sounds like a practical solution if the support team cannot direct us to a more appropriate API method, but again, I'm not really an expert in their system so I cannot say for sure.
Their response:
it depends, under which circumstances would you want to restrict access? And restrict for which users, and under what conditions? And do you want to restrict access to the content of said post using Restrict Content Pro shortcodes, or the entire post?
it depends, under which circumstances would you want to restrict access? And restrict for which users, and under what conditions? And do you want to restrict access to the content of said post using Restrict Content Pro shortcodes, or the entire post?
I'm just trying to understand how the restriction API works. I want to understand how to restrict access to the entire post, not specific content within the post. I want to understand how to use your API to programmatically display a 404 error when visiting a specific post's permalink, under all circumstances all conditions all the time for all Users. This is just an example to understand which API I need to use to restrict access programmatically. Is this the correct filter to programmatically restrict access to an entire post all the time for all users?
// how to display a 404 error at the permalink URL for post #12345 for all users, all the time, all circumstances, all conditions?
function tssupp_filter_rcp_access( $is_restricted, $post_id ) {
if( $post_id == 12345){
return true;
}else{
return false;
}
}
add_filter( 'rcp_is_restricted_content', 'tssupp_filter_rcp_access', 10, 2 );
If not, please provide a working example that will programmatically restrict access to the entire post with ID 12345 for all users, all the time, under all conditions and circumstances, using your PHP API.