• Hi!

    This is my first post to look for help. First of all, i have to apologyse about my english. And now, my hell call ??

    I am registering a custom taxonomy into my functions.php, like this:

    register_taxonomy('palabras-clave', 'sonidos', array(
    		'capabilities' => array(
    		'assign_terms' => 'edit_sonidos',
    	        'edit_terms' => 'edit_sonidos',
    		'manage_terms' => 'edit_sonidos',
    		'delete_terms' => 'edit_sonidos',
    		),
    		'public' => true,
    		'show_ui' => true,
             	'show_admin_column' => true,
    		'show_in_nav_menus' => true,
    		'show_tagcloud' => true,
    		'hierarchical' => false,
    		'label' => 'Palabras clave',
    		'query_var' => true,
    		'rewrite' => true,
    		));

    This taxonomy is linked with a custom post type and it is resgiter into functions.php too, like this:

    add_action('init', 'sonidos_type_register');
    
    		function sonidos_type_register() {
    
    			$labels = array(
    				'name' => __( 'Panel de sonidos' ),
    				'singular_name' => __( 'Sonido' ),
    				'add_new' => __( 'A?adir Nuevo' ),
    				'add_new_item' => __( 'A?adir nuevo sonido' ),
    				'edit_item' => __( 'Editar sonido' ),
    				'new_item' => __( 'Nuevo sonido'),
    				'view_item' => __( 'Ver sonido'),
    				'search_items' => __( 'Buscar sonido'),
    				'not_found' =>  __('No se encontró nada'),
    				'not_found_in_trash' => __('No se encontró nada en la papelera'),
    				'parent_item_colon' => ''
    			);
    
    			$args = array(
    				'labels' => $labels,
    				'public' => true,
    				'rewrite' => true,
    				'capability_type' => array('sonido', 'sonidos'),
    				'capabilities' => array(
    					'publish_posts' => 'publish_sonidos',
    					'edit_posts' => 'edit_sonidos',
    					'edit_published_posts' => 'edit_published_sonidos',
    					'edit_others_posts' => 'edit_others_sonidos',
    					'delete_posts' => 'delete_sonidos',
    					'delete_others_posts' => 'delete_others_sonidos',
    					'read_private_posts' => 'read_private_sonidos',
    					'edit_post' => 'edit_sonido',
    					'delete_post' => 'delete_sonido',
    					'read_post' => 'read_sonido',
    				),
    				'map_meta_cap' => true,
    				'hierarchical' => false,
    				'menu_position' => null,
    				'supports' => array('title'),
    				'taxonomies' => array ('categorias-sonidos','sectores-industriales','periodos-industriales','palabras-clave'),
    			  );
    
    			register_post_type( 'sonidos' , $args );

    Everything works fine, but the editor and contributor can not add ‘palabras-clave’, nor can see / select the existing ones.
    I tried downgrading the level needed to manage terms in the custom taxonomy registered to ‘read’, but it still doesn’t work.

    The capabilities modified are these:

    // Capacidades del editor
    
    	add_action( 'admin_init', 'modify_editor_capabilities' );
    
    	function modify_editor_capabilities(){
    	  global $wp_roles;
    	  $wp_roles->add_cap('editor','read' );
    	  $wp_roles->add_cap('editor','upload_files' );
    	  $wp_roles->add_cap('editor','publish_sonidos' ) ;
    	  $wp_roles->add_cap('editor','edit_sonidos' );
    	  $wp_roles->add_cap('editor','edit_published_sonidos' ) ;
    	  $wp_roles->add_cap('editor','edit_others_sonidos' ) ;
    	  $wp_roles->add_cap('editor','delete_sonidos' );
    	  $wp_roles->add_cap('editor','delete_others_sonidos' ) ;
    	  $wp_roles->add_cap('editor','read_private_sonidos' ) ;
    	  $wp_roles->add_cap('editor','publish_enlaces' ) ;
    	  $wp_roles->add_cap('editor','edit_enlaces' );
    	  $wp_roles->add_cap('editor','edit_published_enlaces' ) ;
    	  $wp_roles->add_cap('editor','edit_others_enlaces' ) ;
    	  $wp_roles->add_cap('editor','delete_enlaces' );
    	  $wp_roles->add_cap('editor','delete_others_enlaces' ) ;
    	  $wp_roles->add_cap('editor','read_private_enlaces' ) ;
    	  $wp_roles->remove_cap('editor','list_users' );
    	  $wp_roles->remove_cap('editor','create_users' );
    	  $wp_roles->remove_cap('editor','edit_users' );
    	  $wp_roles->remove_cap('editor','moderate_comments' );
    	  $wp_roles->remove_cap('editor','manage_categories' );
    	  $wp_roles->remove_cap('editor','edit_published_pages' );
    	  $wp_roles->remove_cap('editor','edit_pages' );
    	  $wp_roles->remove_cap('editor','publish_pages' );
    	  $wp_roles->remove_cap('editor','delete_pages' );
    	  $wp_roles->remove_cap('editor','manage_links' );
    	  $wp_roles->remove_cap('editor','unfiltered_html' );
    	  $wp_roles->remove_cap('editor','delete_posts' );
    	  $wp_roles->remove_cap('editor','publish_posts' );
    	  $wp_roles->remove_cap('editor','edit_posts' );
    	} 
    
    	// Capacidades del colaborador
    
    	add_action( 'admin_init', 'modify_contributor_capabilities' );
    
    	function modify_contributor_capabilities(){
    	  global $wp_roles;
    	  $wp_roles->add_cap('contributor','upload_files' );
    	  $wp_roles->add_cap('contributor','edit_sonidos' );
    	  $wp_roles->remove_cap('contributor','delete_sonidos' );
    	  $wp_roles->remove_cap('contributor','edit_published_sonidos' );
    	  $wp_roles->remove_cap('contributor','publish_sonidos' );
    	  $wp_roles->remove_cap('contributor','edit_others_sonidos' );
    	  $wp_roles->remove_cap('contributor','read' );
    	  $wp_roles->remove_cap('contributor','delete_posts' );
    	  $wp_roles->remove_cap('contributor','publish_posts' );
    	  $wp_roles->remove_cap('contributor','edit_posts' );
    	  $wp_roles->remove_cap('contributor','edit_users' );
    	}

    Thank you in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter joselov

    (@joselov)

    I just found a solution.
    The problem was I had a function to prevent drag of metaboxes and that was generating the conflict. This was made a conflict with the ‘add new terms’ function to taxonomies (hierarchical or not).

Viewing 1 replies (of 1 total)
  • The topic ‘Problems with custom taxonomy capabilities’ is closed to new replies.