Created
May 13, 2012 01:58
-
-
Save imjjss/2670240 to your computer and use it in GitHub Desktop.
only want the Admin to be able to post to.Authors not even be able to see it in the category checklist when composing a new post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add_filter('get_terms', 'restrict_categories'); | |
function restrict_categories($categories) { | |
// If we are in the new/edit post page and not an admin, then restrict the categories | |
$onPostPage = (strpos($_SERVER['PHP_SELF'], 'post.php') || strpos($_SERVER['PHP_SELF'], 'post-new.php')); | |
if (is_admin() && $onPostPage && !current_user_can('level_10')) { | |
$size = count($categories); | |
for ($i = 0; $i < $size; $i++) { | |
if ($categories[$i]->slug != 'site_news') | |
unset($categories[$i]); | |
} | |
} | |
return $categories; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment