Support » Fixing WordPress » Add capabilities to a post type

  • The new post type is ad unit
    I want to add a capability to the subscriber user – to be able to add an ad unit.

    This is my register_post_type function:

    register_post_type( 'addunit',
    			array(
    					'labels' => array(
    							'name' => __( 'ad units' ),
    							'singular_name' => __( 'ad unit' )
    					),
    					'public' => true,
    					'has_archive' => true,
    					'rewrite' => array('slug' => 'addunit'),
    					'supports' => array('title','editor','thumbnail','excerpt','comments'),
    					'capability_type' => 'addunit',
    					'capabilities' => array('edit_addunit','read_addunit')
    			)
    	);

    What happens is:
    1. When I add the ‘capability type’ key – subscibers have all capabilities for this post type.
    2. When I remove the ‘capability_type’ key – subscribers has no capabilities for this post type.

    What do I miss?
    I need the subscriber to be able only to add an ad unit and that’s it. Which is the best way to achieve this?

    Many thanks in advance for your help,
    Michal

  • The topic ‘Add capabilities to a post type’ is closed to new replies.