Title: [Plugin: User Access Manager] Custom Post Types
Last modified: August 19, 2016

---

# [Plugin: User Access Manager] Custom Post Types

 *  [consumers](https://wordpress.org/support/users/consumers/)
 * (@consumers)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/)
 * When adding a regular post the “Access” box displays. I created a new Post type,
   and when i try to create a new post under my new post type, the “Access” box 
   doesn’t Display.
 * [http://wordpress.org/extend/plugins/user-access-manager/](http://wordpress.org/extend/plugins/user-access-manager/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [cavamondo](https://wordpress.org/support/users/cavamondo/)
 * (@cavamondo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754520)
 * Does this plugin supports user management for Cusotm Post Types at all?
 *  [mat_](https://wordpress.org/support/users/mat_/)
 * (@mat_)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754532)
 * It’s a problem that i have too. I’m able to display the box in the edit page 
   of the custom post, but the data isn’t save, the checkbox is always unchecked
   and the custom post always accessible.
    To display the box, i’ve done that: line
   270, i replace the too add_meta_box, by this code:
 *     ```
       if ( function_exists( 'get_post_types' ) ) {
       					$post_types = get_post_types( array(), 'objects' );
       					foreach ( $post_types as $post_type ) {
       						if ( $post_type->show_ui ) {
       							add_meta_box('uma_post_access', 'Access', array(&$userAccessManager, 'editPostContent'), $post_type->name, 'side');
       						}
       					}
       				} else {
                   	    add_meta_box('uma_post_access', 'Access', array(&$userAccessManager, 'editPostContent'), 'post', 'side');
                   	    add_meta_box('uma_post_access', 'Access', array(&$userAccessManager, 'editPostContent'), 'page', 'side');
                   	}
       ```
   
 * Anyone that have more infos please ?
 *  [cboden](https://wordpress.org/support/users/cboden/)
 * (@cboden)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754533)
 * In 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;
            }
       ```
   
 *  [cavamondo](https://wordpress.org/support/users/cavamondo/)
 * (@cavamondo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754534)
 * Reckon this will be included in the next plugin update?
 *  Plugin Author [gm_alex](https://wordpress.org/support/users/gm_alex/)
 * (@gm_alex)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754568)
 * Does the solution works for all of you guys? If yes, I will review the code and
   include it.
 *  [cavamondo](https://wordpress.org/support/users/cavamondo/)
 * (@cavamondo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754569)
 * Yeah please do … would be better to have all the code in the standard plugin 
   instead of hacking it local and then have to re-hack it each time an update is
   released ^^
 *  Thread Starter [consumers](https://wordpress.org/support/users/consumers/)
 * (@consumers)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754583)
 * thank you for the help with this issue. I have very litte knowledge with php.
   i Did the step mat_ suggested with no problem, the patch cboden porvided im have
   a problem adding. I try copy and pasting in to the class files but when i save
   them my site doesnt display. is there specific way to aplying a patch? thanks
   for your help.
 *  Thread Starter [consumers](https://wordpress.org/support/users/consumers/)
 * (@consumers)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754584)
 * Nevermind.. I got it working.
 *  [Eduardo Turiño](https://wordpress.org/support/users/eturi/)
 * (@eturi)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754607)
 * How did you make it work ?
 * Version 1.1.4 Still have problems with custom post types.
 * I did above changes and Im getting 404 not found on restricted pages, not the
   custom message.
 *  [jli](https://wordpress.org/support/users/jli/)
 * (@jli)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754618)
 * I can confirm the solution proposed here is working and is NOT implemented in
   1.1.4.
 * Just wanted to clear things up for those of you who like me thought it was, especially
   because the changelog states it fixes error for custom post types.
 * I think this plugin is really nice.
    I tried rolescoper for a while but i gave
   up because its not what i’m looking for at all and it does far too much, and 
   it’s still bugged a lot (eg: breaks the category hierarchy, which is really a
   core functionnality). I think we should threat backend and front-end content 
   restriction as 2 separated needs in 2 separated plugins!
 * Anyway maybe i’m going a bit offtopic here but i just wanted to say i like this
   plugin for it’s simplicity and i’d be glad to help.
 *  [johnegg](https://wordpress.org/support/users/johnegg/)
 * (@johnegg)
 * [15 years ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754658)
 * consumers, would you mind posting the solution please so others can use it? Simply
   saying “Nevermind…got it working” isn’t very helpful to others.
 *  [carnini](https://wordpress.org/support/users/carnini/)
 * (@carnini)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754693)
 * Wondering if the files will be posted somewhere. I have the same issue of not
   being able to show my custom posts.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘[Plugin: User Access Manager] Custom Post Types’ is closed to new replies.

 * ![](https://ps.w.org/user-access-manager/assets/icon.svg?rev=1563783)
 * [User Access Manager](https://wordpress.org/plugins/user-access-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-access-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-access-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/user-access-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-access-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-access-manager/reviews/)

 * 12 replies
 * 9 participants
 * Last reply from: [carnini](https://wordpress.org/support/users/carnini/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-user-access-manager-custom-post-types/#post-1754693)
 * Status: not resolved