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

    (@mmuro)

    Currently, this is an admin only plugin which means that users logged in and viewing the Dashboard are restricted to certain categories.

    As for visitors to your site, the best way to restrict categories is going to be in your theme. I don’t really have any plans to add this functionality to my plugin, so your theme is probably the best place to do this.

    What you can do is use the is_user_logged_in function. If the user is logged in, you can make your query show all categories. Otherwise, restrict them to what you want.

    Here’s an example that uses query_posts().

    <?php
    if ( is_user_logged_in() ) {
    query_posts();
    }
    else{
    query_posts( cat='-1,-2,-3 );
    }
    ?>

    Basically, what this does is check to see if the user is logged in and, if so, will show you everything. If they are not logged in, the query will exclude certain categories from the loop.

    Thread Starter AivarasFX

    (@aivarasfx)

    Ohh, yes.. it doesn’t work in front-end, we didn’t see it for the first time. πŸ™

    Yes, we tried to embed in template, but this is really painful if we have lots of places in template where we need to block a lot of categories and for a lot of different roles. It gets really messy.

    Your plugin looks simple and does great job in admin area if it could do the same for frontend, that would be great.

    If you are not planning to make it work in frontend, that’s a pity πŸ™

    We tried to find some other plugins for this, but they are way too complex for such a simple thing. Like User Access Manager – dam, they invented the Roles again, why if they are already in wordpress πŸ™‚

    Anyway, your plugin is great and simple!

    +1 AivarasFX !

    I found the “Allow category” but it seems broken with WP 3.3. I don’t understand why is it so hard to find a plugin to restrict access to the simple visitors !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Restrict Categories] Users that are not logged in’ is closed to new replies.