WordPress.org

Ready to get started?Download WordPress

Forums

Restrict Categories
[resolved] restriction by role works. restriction by user does not. (36 posts)

  1. nycgadgetgirl
    Member
    Posted 3 years ago #

    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.

  2. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    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.

  3. nycgadgetgirl
    Member
    Posted 3 years ago #

    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!

  4. nycgadgetgirl
    Member
    Posted 3 years ago #

    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?

  5. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    • 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!

  6. Naz
    Member
    Posted 3 years ago #

    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!

  7. nycgadgetgirl
    Member
    Posted 3 years ago #

    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.

  8. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    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
    )
  9. Naz
    Member
    Posted 3 years ago #

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

  10. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    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?

  11. Naz
    Member
    Posted 3 years ago #

    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.

  12. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    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?

  13. nycgadgetgirl
    Member
    Posted 3 years ago #

    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.

  14. nycgadgetgirl
    Member
    Posted 3 years ago #

    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.

  15. nycgadgetgirl
    Member
    Posted 3 years ago #

    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 )

  16. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    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.

  17. nycgadgetgirl
    Member
    Posted 3 years ago #

    Nope, creating new roles didn't work.

    I just used "Members" to create a new role with the Contributor defaults - read, edit posts and delete posts. I applied that role to my problem user. Restricting categories for the role works, but restricting categories for the individual user does not.

    This is the same behavior I get with the problem user when they have the default Contributor role.

    The only thing that has worked so far is creating a new user. That isn't an option though because I have 40+ contributors on this site and they all have multiple articles. Creating new logins for all of them, reassigning all their posts and getting their profiles set up right again would be a nightmare.

  18. nycgadgetgirl
    Member
    Posted 3 years ago #

    Oh, while I'm here... Here is my current plugin list. Naz and I also have Google Sitemap Generator in common. I didn't notice that the first time I looked at his list. Here is mine:

    addthis
    admin-bar-disabler
    advanced-author-exposed
    akismet
    anywhere
    clicky
    contact-form-7
    edit-flow
    feedburner_feedsmith_plugin_2_3
    google-sitemap-generator
    members
    optimize-db
    organize-series
    query-posts
    restrict-categories
    shadowbox-js
    sitemap-generator
    spiurl
    subscribe-to-comments-reloaded
    thesis-openhook
    thumbnail-for-excerpts
    tinymce-advanced
    wordpress-popular-posts
    wp-security-scan

    PREVIOUSLY, I've used Role Scoper (which crapped out and stopped working properly) and Capabilities Manager, both of which have been uninstalled but may have had an effect it seems. I've deleted all the info for those two plugins from the database.

  19. Naz
    Member
    Posted 3 years ago #

    I would have thought this had something to do with a user capability manager (as I had them installed before), but the installation I'm on now is a new WordPress installation and I've never installed any user role manager plugins on this one before.

    And I have the exact same problem as nycgadgetgirl. I have a lot of contributors and can't just recreate their accounts. They've got posts and everything.

  20. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    I guess the next thing we could try is by manually restricting a category.

    If you guys can go to line 511, remove the $cat_list and type in a category ID.

    Go from $excluded = ' AND t.term_id IN (' . $cat_list . ')'; to $excluded = ' AND t.term_id IN (31)';

    This will make it so any user or role that has categories selected are restricted to a single category. If the users are restricted at this point, then I might have an idea of what's going on. Let me know what happens here.

  21. Naz
    Member
    Posted 3 years ago #

    When I use the category ID of the category that was missing in the array earlier, it doesn't show up (which means the category box is completely empty).

    When I use a different category ID for a category that did show up before, it shows up.

  22. nycgadgetgirl
    Member
    Posted 3 years ago #

    When I did this it restricted the "testuser" user whose restrictions work but it didn't change anything for the "snick" user whose restrictions are not working.

  23. avenuegirl
    Member
    Posted 3 years ago #

    Sorry I missed this thread. I posted in another.

    It was strange, as the plugin was working initially and then went kaput out of the blue - on a site that had no changes done to it.

    It was a test site I was putting together and there were only 2 plugins installed on it. Fresh installation of latest WP.

    I'm hoping to use this plugin in conjunction with a "Bind user to category" plugin which tosses the user into a specific area by default should they not select the category.

    Looking forward to a working update. I'd be happy to toss you access to the test site if you might find it useful in any way.

  24. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    Hey everyone,

    I have been working hard on an update to the plugin which I believe will fix the problems with user restriction. There are some behind the scenes things that I've been working on, too, which is why I haven't responded until now.

    Sit tight and I should have it out tomorrow (hopefully). Thanks for being so patient.

  25. nycgadgetgirl
    Member
    Posted 3 years ago #

    That's awesome Matthew! Thanks for the work you're putting into it. :)

  26. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    Version 1.8 is out now. Download it and please let me know if you are still experiencing problems.

  27. nycgadgetgirl
    Member
    Posted 3 years ago #

    FYI - the page says 1.8 but the update date hasn't changed from 1/20/2011 and the update isn't showing up in my plugin list as available for upgrade. Was able to upgrade by searching for it though. Just letting you know.

    Testing now...

  28. Matthew Muro
    Visual Form Builder Pro
    Plugin Author

    Posted 3 years ago #

    Yeah, the Last Updated thing is an issue that affects a lot of developers, not just me. :/ Supposedly, WordPress is working on fixing it, but I have no idea when it'll be fixed.

    If the plugin doesn't show having an update in your site yet, it's because it checks every so often. Best way to get it immediately is to download and upload to your site.

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

  29. nycgadgetgirl
    Member
    Posted 3 years ago #

    IT WORKS!!!!

    Awesome work Matthew!

    (Oops! Sorry, I wrote this a half hour ago and never hit "Post.")

  30. avenuegirl
    Member
    Posted 3 years ago #

    Hey! cool, downloading this afternoon and will report back on how it goes.

    Thanks so much - really looking forward to using this plugin and it is at a great time for a site I'm doing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic