Support » Plugin: User Access Manager » [Plugin: User Access Manager] Custom Post Types

Viewing 12 replies - 1 through 12 (of 12 total)
  • Does this plugin supports user management for Cusotm Post Types at all?

    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 ?

    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 @@
    -        '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;

    Reckon this will be included in the next plugin update?

    Plugin Author GM_Alex


    Does the solution works for all of you guys? If yes, I will review the code and include it.

    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 ^^

    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.

    Nevermind.. I got it working.

    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.

    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.

    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.

    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.