• Resolved duttoluca

    (@duttoluca)


    Hello.
    I registered a new custom post type, as usual, in functions.php:

    $args = array(
    	"label" => __( "Monumento", "TD" ),
    	"labels" => $labels,
    	"description" => "",
    	"public" => true,
    	"publicly_queryable" => true,
    	"show_ui" => true,
    	"delete_with_user" => false,
    	"show_in_rest" => true,
    	"rest_base" => "",
    	"rest_controller_class" => "WP_REST_Posts_Controller",
    	"has_archive" => false,
    	"show_in_menu" => true,
    	"show_in_nav_menus" => true,
    	"exclude_from_search" => false,
    	"capability_type" => "monumento",
    	"map_meta_cap" => true,
    	"hierarchical" => true,
    	"rewrite" => array( "slug" => "monumento", "with_front" => true ),
    	"query_var" => true,
    	"menu_position" => 49,
    	"menu_icon" => "dashicons-editor-customchar",
    	"supports" => array( "title", "editor", "revisions","page-attributes" ),
    );
    
    register_post_type( "monumento", $args );
    

    But in the URE page I can’t find the capabilities: they’re not present in the general list, and the post type counts 0 capabilities (“Monumenti (0/0)”).

    If I check the capabilities for this post type in $globals

    var_dump($GLOBALS['wp_post_types']['monumento']);
    

    I get the right capability list:

      ["cap"]=>
      object(stdClass)#11058 (15) {
        ["edit_post"]=>
        string(14) "edit_monumento"
        ["read_post"]=>
        string(14) "read_monumento"
        ["delete_post"]=>
        string(16) "delete_monumento"
        ["edit_posts"]=>
        string(15) "edit_monumentos"
        ["edit_others_posts"]=>
        string(22) "edit_others_monumentos"
        ["publish_posts"]=>
        string(18) "publish_monumentos"
        ["read_private_posts"]=>
        string(23) "read_private_monumentos"
        ["read"]=>
        string(4) "read"
        ["delete_posts"]=>
        string(17) "delete_monumentos"
        ["delete_private_posts"]=>
        string(25) "delete_private_monumentos"
        ["delete_published_posts"]=>
        string(27) "delete_published_monumentos"
        ["delete_others_posts"]=>
        string(24) "delete_others_monumentos"
        ["edit_private_posts"]=>
        string(23) "edit_private_monumentos"
        ["edit_published_posts"]=>
        string(25) "edit_published_monumentos"
        ["create_posts"]=>
        string(15) "edit_monumentos"
      }
    

    It seems like URE can’t list all the capabilities…
    The strange thing is I have a lot of older custom post type in my functions.php, and they all work as expected.

    Is there a maximum number of capabilities URE can list? Or am I doing anything wrong?

    Thanks

    • This topic was modified 4 years, 11 months ago by duttoluca.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter duttoluca

    (@duttoluca)

    One more detail, maybe it helps: in another site, with URE version 4.52, the capabilities are correctly added / listed.
    In my main site, with URE version 4.52.1, capabilities from custom post type aren’t added anymore.

    Thanks

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi,

    Just tested your CPT registering code as a must-use plugin hooked to ‘admin_init’. It works as expected at my test site. Add ‘_monumentos’ capabilities to the ‘administrator’ role and shows them under “Custom post types->Monumentos” group.

    Do you have WP built-in ‘administrator’ role at your site? In case it was renamed you need to add a custom filter ‘ure_cpt_editor_roles’. It takes 1 parameter: array $roles with 1 element ‘administrator’ by default. Add other role(s) to which you wish URE automatically add user capabilities for editing custom post types, if role does not have such permissions.

    version 4.52.1 includes especially this update.

    Thread Starter duttoluca

    (@duttoluca)

    Thank you for your quick reply.

    Yes, I have the “administrator” role in my site, I didn’t delete it…
    I’m in a multisite environment, can it be the problem?

    Thread Starter duttoluca

    (@duttoluca)

    As you suggested, the ‘ure_cpt_editor_roles’ filter works as expected.

    function filter_ure_custom_roles_add( $roles ) {
        $roles = array("administrator", "tutto");
        return $roles;
    }
    add_filter( 'ure_cpt_editor_roles', 'filter_ure_custom_roles_add' );

    Thank you.

    • This reply was modified 4 years, 11 months ago by duttoluca.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Capabilities list not showing in URE’ is closed to new replies.