Community Support Forums — WordPress® ( Users Helping Users ) — 2011-04-08T20:56:28-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=3042 2011-04-08T20:56:28-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3042&p=9388#p9388 <![CDATA[Re: Listing Categories]]>

Statistics: Posted by Cristián Lávaque — April 8th, 2011, 8:56 pm


]]>
2011-04-08T20:26:32-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3042&p=9384#p9384 <![CDATA[Re: Listing Categories]]> Statistics: Posted by vitorclaw — April 8th, 2011, 8:26 pm


]]>
2011-04-08T20:11:38-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3042&p=9382#p9382 <![CDATA[Re: Listing Categories]]>

I'm just curious, what do you need the $i there for?

For the benefit of others: that example can be found under WP Admin -> s2Member -> API / Scripting -> Advanced Query Conditionals.

Statistics: Posted by Cristián Lávaque — April 8th, 2011, 8:11 pm


]]>
2011-04-08T14:58:50-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3042&p=9369#p9369 <![CDATA[Re: Listing Categories]]>
Example #4: Checking Category Restrictions.

Code:
<?php
if 
($categories = get_categories ())
    {
        foreach ($categories as $category)
            {
                if (!is_permitted_by_s2member ($category->cat_ID, "category"))
                    continue;
                /* Skip it. The current User/Member CANNOT access this Category,
                or any Posts inside this Category, or any of its sub-Categories. */
            }
    }
?>


EDIT:

By the way, the only way to display categories that i found is doing something like this:

Code:
if ($categories = get_categories ()) {
    $i = 0;
    foreach ($categories as $category) {
        if (!is_permitted_by_s2member ($category->cat_ID, "category"))
            continue;
        $variables = get_object_vars($category);
        echo $variables['name'];
        $i++;
    }
}
 

Statistics: Posted by vitorclaw — April 8th, 2011, 2:58 pm


]]>
2011-04-08T14:48:23-05:00 http://www.primothemes.com/forums/viewtopic.php?t=3042&p=9368#p9368 <![CDATA[Listing Categories]]>
Now my question:

I have a blog where I display the 10 latest posts, and on the sidebar I have a list with all my categories generated by wp_list_categories();

The thing is, I would like to exclude categories that are blocked for a certain type of user. (I'm currently using the Alternative view protection, but it doesn't affect this function)

Is there any way to do that?

What i could do if there isn`t any avaiable option to do that is to get all Categories that are blocked ID and insert it into the function so it would be something like:
$blocked_cats;
wp_list_categories("exclude=$blocked_cats");

But I don`t really know how to get those categories.

So I hope you guys can help me. Thanks

Statistics: Posted by vitorclaw — April 8th, 2011, 2:48 pm


]]>