Change WordPress user roles and capabilities › Forums › How to or FAQ › limit Categories to be selected for a Post
- This topic has 8 replies, 2 voices, and was last updated 3 years, 7 months ago by edering.
14/10/2019 at 15:32 #6019
I know I can set a User to have Editor Restrictions for a Category/Taxonomy ID. I tried that. When the user create a Post (for a specific Custom Post Type), then the User’s Post has that Category pre-selected, BUT also has the ability to select and save the other Categories. And I don’t wan this User to be able to create Categories, so Manager Categories is not set for this Role. How I prevent them from choosing the other possible categories so their content does not show up on Pages we have that query Categories?15/10/2019 at 15:37 #6021
User with ‘edit restrictions’ should see at the post editor only “allowed” categories. If you allow 1 category, only that single category should be shown at the categories list. If it does not work as I described, I’m ready to check your settings online. I will need admin privileges for that. If this is possible, send credentials to support [at-sign] role-editor.com15/10/2019 at 15:52 #6023
Please look with the Admin rights I just emailed you. I created a user (which you can create one too if you want) that was a SDoL Page Editor, and News for the other Role. And I have one Page/Post ID Allowed (but it is showing All Pages), and one Category ID (for “McCaskey Campus” in the News categories). https://www.screencast.com/t/eG2WTzPPzb When I go to News and click Add New, this is what happens – https://www.screencast.com/t/QH2I2cz6z – it preselects the one Category I had in the Allow, but it let’s me see and choose any of the others.16/10/2019 at 03:17 #6026
You turned OFF edit restrictions for ‘news’ custom post type. This is a reason why user is not restricted edit this CPT by category you set at this user profile. As you comment/remove exclude_posts_from_edit_news_restrictions, user will still can add new news, but only to this single category and see at the news list news only with this category.16/10/2019 at 12:24 #6029
Where is it that I turned off Edit Restrictions for ‘news”? In the filter? In the code you just sent me in the other forum topic, you still have restrict_it=false. Is that right? Now when i login and test a user with SDoL Page Editor and News (with restrictions to a single category, I still see the News that has that category, but I still can add ore than one News Category, beyond the one I Allowed. in this screen, it shows the User I described above and it shows that I was able to publish to a category that I did set to be Allowed. Only McCaskey should be allowed. https://www.screencast.com/t/84YqUIGu3k816/10/2019 at 12:32 #6030
$restrict_it = false;
When filter returns FALSE, URE does not apply any restrictions for this post type.
Why do not comment/remove exclude_posts_from_edit_news_restrictions() from the filter?
User will still can add new news, but only to this single category ‘McCaskey’ and see at the news list news only with this category.16/10/2019 at 12:38 #6032
ok, I will try that. Do I get rid of only the entire add_filter line and keep the function as is? https://www.screencast.com/t/hpt7aZDzvXd16/10/2019 at 12:43 #6033
This function itself is not needed without filter line. So you may remove a whole part of the code: function with the filter line together.16/10/2019 at 12:49 #6034
Thanks! That did it. You are amazing. I got confused because I did something similar for the Scholarships CPT but I guess the difference is that the filter/function for Scholarships was only because I did NOT want to restrict those at all by Post/Page ID and Users that have that role ALSO have Page ID Restrictions, so that separated it. Now I get it! Thanks
- You must be logged in to reply to this topic.