WordPress.org

Support

Support » Plugins and Hacks » Restrict Categories » [Resolved] [Plugin: Restrict Categories] restriction by role works. restriction by user does not.

[Resolved] [Plugin: Restrict Categories] restriction by role works. restriction by user does not.

  • Problem: I’ve installed and activated Restrict Categories. Restricting based on role works great, but restricting based on username doesn’t work at all. The by user restriction is what I desperately need though. I’ve read the other forum posts and haven’t found anyone having the same problem. I must be missing something. Help?

    Environment: I just installed Restrict Categories 1.7 last night. I’m running WordPress 3.1. I don’t have any user or role management plugins installed. I was using Role Scoper up until a couple months ago, but I uninstalled it (and dropped its database tables in phpMyAdmin) after I deactivated it. I installed, tested, and uninstalled a couple of role management plugin this weekend as well, but they were uninstalled before Restrict Categories was installed.

Viewing 15 replies - 1 through 15 (of 35 total)
  • Plugin Author Matthew Muro

    @mmuro

    Sorry you are having trouble. Can you give me some more details about what’s going on?

    Since you said you had Role Scoper installed, you could try installing Members and confirming that the capabilities match up with the WordPress default caps.

    I’m not too familiar with how Role Scoper manages the capabilities, but WordPress stores its roles and capabilities in the wp_usermeta table.

    The users that I’m trying to restrict are Contributors. I don’t _think_ Role Scoper would have changed anything permanently about the role/capabilities that wouldn’t be obvious, but anything is possible! I will install Members tonight and let you know what I learn. Thanks!

    I installed Members and enabled the roles module. I checked the my Contributor role has only the three capabilities it should have. I tried again to restrict categories for a specific user. It did not work. What else can I do or look it to try to figure this out?

    Plugin Author Matthew Muro

    @mmuro

    • Does that user see any posts listed?
    • In the Posts category filter dropdown, do you see the categories selected in the Restrict Categories screen?
    • If you change the role to something like Author or Editor, are things any different?
    • On the Add New Posts screen, does the Categories box contain the selected restricted categories?

    If you can provide that information, that might help determine what’s going on. Thanks!

    I was about to post about this when I read this post. I’m having the same problem.

    This is what I know:

    • It doesn’t work for users with the Administrator user role.
    • It doesn’t work for users with the Editor user role.
    • It doesn’t work for users with the Author user role.
    • It doesn’t work for users with the Contributor user role.
    • The selected restricted categories do not show up on the Add New Posts screen.
    • The restricted categories don’t show up in the Filter dropdown menu on the Posts page.
    • The restricted categories do work properly for user roles, but not for individual users.
    • When restricted categories are selected for an individual user, it still shows the restricted categories selected for the user role of that user.
    • The individual user can see all posts posted/scheduled in the restricted categories of their user role.

    I hope that helps. Thanks!

    mmuro,

    Sorry for the delay in answering your questions.

    Does that user see any posts listed?

    Yes, the user does see posts listed.

    In the Posts category filter dropdown, do you see the categories selected in the Restrict Categories screen?

    Yes, I see them (as the admin) and so does the user I’m trying to restrict. We both see all categories.

    If you change the role to something like Author or Editor, are things any different?

    Changing the user’s role doesn’t change anything. Categories are still not restricted.

    On the Add New Posts screen, does the Categories box contain the selected restricted categories?

    On the New Post screen the user sees ALL categories.

    Plugin Author Matthew Muro

    @mmuro

    Okay, let’s troubleshoot with some code!

    Paste this onto line 423 and tell me the output. It should display each user in an array and for those with restricted categories selected, you will see those categories listed.
    print_r($settings_user);

    For example:

    Array
    (
        [admin_user_cats] =>
        [chip-bennett_user_cats] =>
        [editor_user_cats] =>
        [ian-stewart_user_cats] =>
        [lance-willett_user_cats] =>
        [test_user_cats] => Array
            (
                [0] => aciform
            )
    
    )

    The next thing you can try is pasting the following code into line 497. It should display the IDs of whatever categories you selected for that user. Note, this will only display for the user on the Posts screen, so you’ll have to login as that user in order to see it.
    print_r($query->query_vars['category__in']);

    Here’s the output (using the category and user from above):

    Array
    (
        [0] => 9
    )

    The array displays the categories correctly:

    [username_user_cats] => Array
            (
                [0] => arts-culture
                [1] => animals-wildlife
                [2] => environment-conservation
                [3] => children-youth
                [4] => health
                [5] => human-rights
                [6] => social-welfare
                [7] => volunteering
                [8] => photolog
                [9] => unpublished
            )

    The array for that user is:

    Array ( [0] => 124 [1] => 17 [2] => 19 [3] => 18 [4] => 20 [5] => 21 [6] => 123 [7] => 16 [8] => 14 )
    So it looks like there’s no [9].

    Plugin Author Matthew Muro

    @mmuro

    No idea why it would be doing that. It should at least be restricting the user to those categories, even though the last one is missing.

    What other plugins are you running?

    Um… I have quite a few installed, but I haven’t installed any new ones lately.

    Here’s a list of plugins in my plugin folder:
    add-to-any
    akismet
    all-in-one-slideshow
    auto-logout
    cleverness-to-do-list
    custom-contact-forms
    dashboard-heaven
    dashboard-message-for-wordpress
    disqus-comment-system
    dropdown-menu-widget
    easy-timer
    edit-flow
    genki-pre-publish-reminder
    google-sitemap-generator
    igit-related-posts-with-thumb-images-after-posts
    im8-box-hide
    maintenance-mode
    myeasyhider
    people-lists
    private-messages-for-wordpress
    register-plus-redux
    restrict-categories
    revisionary
    seo-ultimate
    shortcode-exec-php
    simple-mail-address-encoder
    smart-youtube
    social-media-widget
    threewp-activity-monitor
    twitter-blackbird-pie
    twitter-tools
    user-switching
    web-ninja-comment-count-fixer
    wordpress-faq-manager
    wordpress-importer
    wp-admin-microblog
    wp-db-backup
    wp-footnotes
    wp-missed-schedule
    wp-paginate
    wp-relative-date

    Edit: The plugin appears to work for older categories, but when I create a new one and select it for the individual user, it doesn’t work.

    Edit 2: The plugin does work for the categories listed in that array (the 2nd one). It’s [9] that doesn’t appear.

    Plugin Author Matthew Muro

    @mmuro

    Wow that is quite a list! I was going to see if there was a conflict somewhere but that’s not going to be possible.

    Is the last category that doesn’t show up a new one?

    I haven’t had a chance yet to do the troubleshooting, but, if it helps, the only plugins that Naz and I have in common are: Akismet, Edit Flow, and Restrict Categories.

    Also, none of my categories are new. The plugin isn’t working on a user level for any of my categories as far as I can tell.

    I just figured out something important. I created a new contributor and applied the exact same restrictions that I was trying to apply to my other writer and it worked perfectly. It works with new writers and not existing writers.

    I believe there is something wrong in my database – possibly from a previous plugin – that is causing this problem with Restrict Categories.

    troubleshooting task one. The two users look the same.

    This is the user that isn’t being restricted properly:
    [snick_user_cats] => Array ( [0] => art [1] => blogs [2] => books )

    This is the new user:
    [testuser_user_cats] => Array ( [0] => art [1] => blogs [2] => books )

    troubleshooting task two.

    The user that isn’t being restricted properly:
    Array ( [0] => 20 [1] => 50 [2] => 16 [3] => 6 [4] => 13 [5] => 26 [6] => 397 [7] => 18 [8] => 52 [9] => 22 [10] => 21 [11] => 1328 [12] => 228 [13] => 1040 [14] => 259 [15] => 208 [16] => 44 [17] => 53 [18] => 1524 [19] => 396 [20] => 42 [21] => 43 [22] => 25 [23] => 14 [24] => 294 [25] => 10 [26] => 155 [27] => 342 [28] => 603 [29] => 17 [30] => 5 [31] => 4 [32] => 47 [33] => 156 [34] => 48 [35] => 23 [36] => 45 [37] => 11 [38] => 24 [39] => 521 [40] => 1286 [41] => 12 [42] => 534 [43] => 41 [44] => 974 [45] => 297 )

    The new test user:
    Array ( [0] => 50 [1] => 16 [2] => 6 )

    Plugin Author Matthew Muro

    @mmuro

    I just figured out something important. I created a new contributor and applied the exact same restrictions that I was trying to apply to my other writer and it worked perfectly. It works with new writers and not existing writers.

    This almost certainly tells me that the capabilities for each role have been altered due to prior user management plugins. Naz, this might be your issue, too.

    I’d recommend doing exactly what you did: create new roles with the default WordPress capabilities. I know it might not be ideal but at least you’ll get the plugin working like it should. Let me know if it works.

Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘[Resolved] [Plugin: Restrict Categories] restriction by role works. restriction by user does not.’ is closed to new replies.
Skip to toolbar