WordPress.org

Ready to get started?Download WordPress

Forums

Trying to limit categories by user level (2 posts)

  1. Daddio
    Member
    Posted 10 years ago #

    I finally figured this out...it's amazing what a little Stoli will do for you...er...me. I honestly don't know if this is the "correct" solution, but it works.
    Here is the top of my index.php file now, after my "hacks":

    <?php
    /* Don't remove these lines. */
    $blog = 1;
    require('wp-config.php');
    get_currentuserinfo();
    if ( $user_level == "0" || ! isset($user_level) ) { $cat = 1; }
    elseif ( $user_level == "1" ) { $cat = '1 2'; }
    require('wp-blog-header.php');

    I looked around the code some more, and found that I needed the wp-config.php file code in order to get the get_currentuserinfo() function. So, I just started playing, and TaDa! I have something that works. And it should be pretty portable to "updated" versions of index.php. It would be really nice if this ability (obviously not this code) could be considered for inclusion in WP, but my simple hack will do what I am looking to do.
    One other note: I saw a lot of references to $cat='1,2' in other posts, and that was really messing me up, as the proper syntax is like I have it above - $cat='1 2' - with the space and not the comma. Just thought I would point that out for anyone else having problems.

  2. oerdec
    Member
    Posted 10 years ago #

    Hi Daddio,
    Thanks for this hack! I searched for a solution to protect some categories with passwords. I think to limit access by user-level is much better.
    One thing is still missing: The categories users with level 0 are not allowed to see should not appear in the list. But it may not be a big problem.
    oerdec//

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.