[Resolved] Access Plugin not restricting guest access to specific CPT Archive
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to change the custom post type URL param in query string.
Solution:
To change the custom post type URL param 'post_type' to post type slug you need to follow the following steps:
=> Navigate to Toolset => Post Types and Edit your post type
=> Under section "Options" add the query_var name as per your requirement and save the post type
=> Go to Settings => Permalinks and save the permalinks.
Relevant Documentation:
This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I have 2 CPTs created with toolset. 1 is a Parent and the other a Child.
These are both managed by access with GUEST readability turned off. If I visit the site url and (for example only) do:
hidden link
I get "no records found". This is an expected outcome as I have defined both a "Template" for the single post type and an "Archive" page to display posts that belong to the logged in user.
However, if I visit the site as a GUEST and access the Child CPT archive in the browser like this :
hidden link
It returns all of the Child posts archives by post title. Although, clicking on any of the individual posts does return a 404 page, this content (Controlled By Access) should not even be accessible to a guest. I do not have a Template or Archive page created for this CPT, but I don't see what I would need one.
Furthermore, because I am displaying this child content in a very specific way on the frontend in a VIEW, this Child CPT shouldn't even return content to the logged in user through the url query in this way
I have read wp-types documentation thoroughly and have a defined access group for member content. Again, this seems to be fine on the Parent CPT but not the Child CPT.
Lastly, in Types, I see this option below:
query_var
Disable to prevent queries like "mysite.com/?post_type=example". Enable to use queries like "mysite.com/?post_type=example". Enable and set a value to use queries like "mysite.com/?query_var_value=example"
Default: true - set to $post_type.
This is checked by default for both of my CPTs, but checking or unchecking does not seem to have any effect.
How do I ensure any guest visting a CPT archive directly does not have access? A default or custom 404 would be fine.
There are two additional options you can choose for archive pages:
Display the "No posts found" message.
Choose a different PHP template to render the contents.
<strong>Please note that the options for selecting what to display for archive pages is are only available when one of the following conditions is met: </strong>
1) If you are using Layouts, your theme must be integrated with Layouts.
2) If you are not using Layouts, there must be at least one WordPress Archive in your site, that you created with the Views plugin.
Could you please confirm that one of the condition is met in your case as well. If yes:
This seemed to work with the desired outcome. Wouldn't this be the most direct solution?
Additionally, if that had not been the solution, could you provide information on my the question above about the query_var check box on the CPT and why this has no effect?
I see this option below:
query_var
Disable to prevent queries like "mysite.com/?post_type=example". Enable to use queries like "mysite.com/?post_type=example". Enable and set a value to use queries like "mysite.com/?query_var_value=example"
Default: true - set to $post_type.
This is checked by default for both of my CPTs, but checking or unchecking does not seem to have any effect.
This seemed to work with the desired outcome. Wouldn't this be the most direct solution?
=> Yes - it should be but your original question was to restrict using access but if this solution fits into your requirement then you can go with that. No harm using it.
To check "query_var" could you please do following:
- Create new post type news
- Create new post for news post type with title "testnews"
- Now, to check if "query_var" works or not try to load following URL is it working?:
=> mysite.com/?news=testnews