WordPress.org

Ready to get started?Download WordPress

Forums

Custom capability/role issues in 3.0 w/ custom post type. (2 posts)

  1. wilsmex
    Member
    Posted 3 years ago #

    Need help in resolving / replicating this issue.

    I've registered a custom post type in 3.0 and instead of using the default "post" to check capabilities against, i'm using a "articles".

    (This way I can then let say my "subscribers" view, edit, etc my "articles", but not be able to do anything with "posts")

    The problem is that it partially works, but it lets me edit "others" peoples articles as well.

    register_post_type('articles', array(
    		'labels' => array(
    			'name' => __( 'Articles' ),
    			'singular_name' => __( 'Article' ),
    		'description' => 'Hunting Articles',
    		'public' => true,
    		'show_ui' => true,
    		'_builtin' => false,
    		'capability_type' => 'article',
    		'hierarchical' => false,
    		'rewrite' => array("slug" => "articles"), // Permalinks
    		'query_var' => "articles",
    		'supports' => array('title','author', 'excerpt', 'editor','thumbnail','comments')
    	));

    Here is my code to add the new capabilities to the subscriber role.

    $edit_subscriber = get_role('subscriber');	
    
    $edit_subscriber->add_cap('edit_article');
    $edit_subscriber->add_cap('edit_articles');
    $edit_subscriber->add_cap('read_article');
  2. MichaelH
    Member
    Posted 3 years ago #

    Is it the 'edit_others_articles' capability you want with remove_cap?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.