User Access Manager
Custom Post Types (13 posts)

  1. consumers
    Posted 5 years ago #

    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.


  2. cavamondo
    Posted 5 years ago #

    Does this plugin supports user management for Cusotm Post Types at all?

  3. Mat_
    Posted 5 years ago #

    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 ?

  4. cboden
    Posted 5 years ago #

    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;
  5. cavamondo
    Posted 5 years ago #

    Reckon this will be included in the next plugin update?

  6. GM_Alex
    Plugin Author

    Posted 5 years ago #

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

  7. cavamondo
    Posted 5 years ago #

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

  8. consumers
    Posted 5 years ago #

    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.

  9. consumers
    Posted 5 years ago #

    Nevermind.. I got it working.

  10. Eduardo TuriƱo
    Posted 5 years ago #

    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.

  11. jli
    Posted 5 years ago #

    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.

  12. johnegg
    Posted 5 years ago #

    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.

  13. carnini
    Posted 4 years ago #

    Wondering if the files will be posted somewhere. I have the same issue of not being able to show my custom posts.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Access Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic