Change WordPress user roles and capabilities Forums How to or FAQ limit Categories to be selected for a Post

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #6019
    edering
    Participant

    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?

    #6021
    Vladimir
    Keymaster

    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.com

    #6023
    edering
    Participant

    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.

    #6026
    Vladimir
    Keymaster

    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.

    #6029
    edering
    Participant

    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/84YqUIGu3k8

    #6030
    Vladimir
    Keymaster

    Yes,

    
    $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.

    #6032
    edering
    Participant

    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/hpt7aZDzvXd

    #6033
    Vladimir
    Keymaster

    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.

    #6034
    edering
    Participant

    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

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.