• I discovered (and fixed) a show-stopper bug in Keith McDuffee’s otherwise excellent Category Visibility plugin (http://www.gudlyf.com/archives/2005/03/08/wordpress-plugin-category-visibility/).

    ——————
    BUG DESCRIPTION: Creating a new category or subcategory leaves the catvis_user_level blank, resulting in no one being able to see the category or its posts.

    In lay language, Category Visibility includes on its Manage page a “user level” field for every category and subcategory. Only users at or above that user level (WP 1.5x user levels) can see the category or posts within it. Setting the field to 0 allows all everyone (including non-registered users) to see them. Leaving the field blank, however, means the cateogry and its contents are invisible to everyone of any user level (including the admin at level 10).

    When creating a new category, Category Visibility defaults to leaving the category visibility user level field blank. Thus, for every new category, someone (with adequate permissions) has to go manually change that on the Category Visibility Manage page.

    ——————
    RESOLUTION: Replace a line in the Category Visibility Plugin (category_visibility.php) code. (Don’t get squeamish! This is easy!)

    Open category_visibility.php in a text editor and locate line #106, which is this code:

    $catvis_user_level = $catvis->user_level;

    Now replace that entire line with this:

    if ($catvis->user_level == ” ) $catvis_user_level = “0”; else $catvis_user_level = $catvis->user_level;

    ——————
    WHAT’S IT DOING: (I SWEAR I am NOT a programmer!) As Keith wrote the original code, the field $catvis_user_level is being told to look up the value of field $catvis->user_level. When $catvis->user_level already has a value (meaning you went in and set a user level for that category), everything works fine; the value you set merely gets shown again as you set it. But, when you create new categories, $catvis->user_level starts out blank. Thus $catvis_user_level also becomes blank, making all newly created categories totally invisible at creation time.

    There’s error-checking built into Keith’s script such that, if user_level is blank, it should be set to 0 automatically. Unfortunately, that’s failing for some reason (at least it is on my four WP installs).

    In the corrected code, $catvis_user_level also looks up the value of $catvis->user_level, using whatever value is there. BUT, if $catvis->user_level happens to be blank, then $catvis_user_level sets itself to (visible to user level) 0 (and above). The result is that newly created categories are visible to everyone by default instead of INvisible to everyone by default.

    ——————
    VARIANT: If your needs differ–say, you want newly created categories to be visible only to users level 4 and above–just change $catvis_user_level = “0” to $catvis_user_level = “4” or whatever you need.

    ASIDE: I apologize to the PHP-literate for my verbosity above. I recognize that I could have simply posted the original and replacement code without explanation. However, many WP users don’t understand the typical “replace ‘this’ with ‘this'” help often found in this forum (I know I didn’t when I was first trying to figure out all of this PHP stuff). More to the point, I always like to give people the courtesy of explaining WHY to choose to do something rather than just HOW.

Viewing 6 replies - 1 through 6 (of 6 total)
  • That still doesn’t work for me. I have to go into Manage->Category Visibility and click on Submit Changes to make it work. It does put the 0 in there, but it doesn’t update the database it seems. Is there something else I’m missing?

    Yeah.. I’ve tried this multiple times and the Category Visibility doesn’t work.

    Installed totally fine, but when unchecking front it removes it from everywhere including that category and i’m unable to search the item.

    Im sure others have had problems

    i’m using .31 version on wordpress 2.0

    Kenny

    for anyone else.. here is the fix

    http://tova.fena.se/2005/06/11/category-visibility/

    ^^
    Works fine within firefox but we’re having some problems with this within ie

    Sorry to post soo many times within this thread but i don’t see an edit or delete function.

    I had users set at 0… this needs to be set at -1

    I can’t see the category list in my homepage…this is the function:

    <div id=”box”>

      <?php wp_list_cats(‘sort_column=id&optioncount=1’); ?>

    </div>

    it’s not in the sidebar

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Category Visibility Plugin – Fixed a bug’ is closed to new replies.