Support » Plugin: Restrict Categories » [Plugin: Restrict Categories] Create, manage and use child categories for restricted users

  • Hi,
    In order to create an intranet, I needed to manage access to the different categories in the site.

    I used Restrict categories (combined with User Role Editor) until I had to face a major problem: restricted users could create a sub category in those they had access to, but only when creating it through a post, and couldn’t access it anymore after, couldn’t see it in the category manager, and so couldn’t add any more post in it.
    The only way would be that administrator manages sub categories which is not to consider.

    So, my main question is: is there a way for restricted users to have a full control of the child categories they need to create in their own categories?

    Continuation of my story. As I had this problem, I tried other plugins and found Advanced access manager, which replaced perfectly both Restrict Categories and User Role Editor, as long as I tested it on my own server. But it refused to work at my clients… So, I switched back to Restrict Categories and User Role Editor, did my categories restrictions by users again (I have about 50 users now, but more will come), SAVED of course, but each time I change the page to manage other users, all the buttons I checked got unchecked…

    As it’s an intranet, I can’t go at my clients easily, and I did not have enough time to clean the tables yet, so I get this could cause my problem. But I wanted to know anyway if there was something else to suspect…

    Excuse my english (I’m french), hope I’m clear in my explainations…
    And in advance, thanks for any help you could give me.

    http://wordpress.org/extend/plugins/restrict-categories/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter alineo

    (@alineo)

    Hi,
    as no one answered, and as we were in a little hurry in this project, we went into the plugin’s code to make some changes.
    I know it’s not a clean way to get what we need, that’s why I wanted to show you the code.

    We had, on lines 409 and 428:

    $subcats = get_categories('hierarchical=1&hide_empty=0&child_of='.$term_id);
    foreach ($subcats as $subcat)    {
      $maSousCatID=$subcat->cat_ID;
      $this->cat_list .= $maSousCatID . ',';
    }

    I repeat, the idea was to display sub categories when created by restricted user in his own category.

    Could anyone tell me if there’s a nicer way to change the code?

    Thanks.

    Hello alineo,
    could you be more precise to where to put your lines of code in the original code please ? Maybe if you can give me some of the original code that’s before and after your changes ?

    Thanks a lot
    Merci
    David

    I have used the below code to give me the sub categories of selected categories.
    You add the following code twice:

    $subcats = get_categories('hierarchical=1&hide_empty=0&child_of='.$term_id);
    foreach ($subcats as $subcat)    {
      $this->cat_list .= ($subcat->cat_ID . ',');
    }

    on the next lines after:

    $this->cat_list .= $term_id . ',';

    which are originaly at line numbers 409 and 428.
    So you should have the following code twice:

    $this->cat_list .= $term_id . ',';
    $subcats = get_categories('hierarchical=1&hide_empty=0&child_of='.$term_id);
    foreach ($subcats as $subcat)    {
      $this->cat_list .= ($subcat->cat_ID . ',');
    }

    The extra lines of code obtain the sub categories of the category ($term_id) that the user can view.

    Thread Starter alineo

    (@alineo)

    Whoa, so much more efficient, cleverly thought.
    Thanks a lot.

    Still we have a problem.
    When a restricted user creates a new sub category, in a post, he can see all the categories until the post is published.
    Of course the new category is checked, as usual, but now the restricted user could also check any other category…

    Any idea about that?

    Thanks for that tweak – it’s made the difference between me using the plugin and rejecting it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Restrict Categories] Create, manage and use child categories for restricted users’ is closed to new replies.