cboden
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [User Access Manager] [Plugin: User Access Manager] Custom Post TypesIn addition to what Mat_ contributed, here is a patch for two of the class files to make post custom types save as well as restrict theme access:
Index: UserAccessManager.class.php =================================================================== --- UserAccessManager.class.php (revision 6) +++ UserAccessManager.class.php (working copy) @@ -345,10 +345,9 @@ foreach ($objectTypes as $objectType) { $addition = ''; - - if ($objectType == 'post' - || $objectType == 'page' - || $objectType == 'attachment' + + $uamah = $this->getAccessHandler(); + if (in_array($objectType, $uamah->postables) ) { $dbIdName = 'post_id'; $database = $dbAccessgroupToPost.', '.$wpdb->posts; @@ -1442,7 +1441,7 @@ $postType = $post->post_type; - if ($postType == 'attachment') { + if (in_array($postType, $uamAccessHandler->postables)) { $postType = 'post'; } elseif ($postType != 'post' && $postType != 'page') { return $post; @@ -1564,9 +1563,9 @@ { $showItems = array(); - foreach ($items as $item) { - if ($item->object == 'post' - || $item->object == 'page' + foreach ($items as $item) { + $uamAccessHandler = &$this->getAccessHandler(); + if (in_array($item->object, $uamAccessHandler->postables) ) { $object = get_post($item->object_id); $post = $this->_getPost($object); Index: UamAccessHandler.class.php =================================================================== --- UamAccessHandler.class.php (revision 8) +++ UamAccessHandler.class.php (working copy) @@ -41,10 +41,12 @@ 'attachment', 'category', 'user', - 'role' + 'role', ); protected $allObjectTypes = null; protected $sqlResults = array(); + + public $postables = Array('post','page','attachment'); /** * The consturctor @@ -55,6 +57,14 @@ */ public function __construct(&$userAccessManager) { + $post_types = get_post_types( array(), 'objects' ); + foreach ($post_types as $post_type) { + if ($post_type->publicly_queryable) { + $this->objectTypes[] = $post_type->name; + $this->postables[] = $post_type->name; + } + } + $this->userAccessManager = $userAccessManager; }
Viewing 1 replies (of 1 total)