• Hi,

    I use on WordPress Network Custom Post type “CV LISAA” and a specific role “lisaa_members” for these post type (please see code bellow).

    On this role, with the plug-in, I add all Cabilities (like in this screenshoot). Everything works well except one thing. Even, if I don’t check the “edit_others_atelierposts”, all the “lisaa_members” can edit other post type.

    Is there somebody else have this kind of problem with a solution?
    Thanks in advance

    <?php
    
    /* Set up the post types. */
    add_action( 'init', 'gncomwp_ateliers_lisaa_labo_register_post_types',0 );
    
    /* Registers post types. */
    function gncomwp_ateliers_lisaa_labo_register_post_types() {
    
        /* Set up the arguments for the 'ateliers_lisaa_labo' post type. */
    
        $labels_lisaa_labo = array(
                'name' => 'CV LISAA',
                'singular_name' => 'CV LISAA',
                'add_new' => 'Ajouter votre CV',
                'add_new_item' => 'Ajouter votre CV',
                'edit_item' => 'Editer votre CV',
                'new_item' => 'Nouveau CV',
                'view_item' => 'Voir le CV',
                'search_items' => 'Chercher dans les CV',
                'not_found' => 'Aucun CV n\'a été trouvé',
                'not_found_in_trash' => 'Aucun CV n\'a été trouvé dans la corbeille'
            );
    
        $ateliers_lisaa_args = array(
        	'labels' => $labels_lisaa_labo,
            'public' => true,
            'show_in_nav_menus' => false,
            'query_var' => 'ateliers_lisaa_labo',
            'rewrite' => array(
                'slug' => 'ateliers-lisaa-labo',
                'with_front' => false,
            ),
            'menu_position'=> 25,
            'menu_icon'=> get_stylesheet_directory_uri() . '/images/lisaa-labo.png',
            'supports' => array(
                'title',
                'thumbnail',
     			'author',
            ),
           'capability_type' => 'atelierpost',
            'capabilities' => array(
    			'edit_post' => 'edit_atelierpost',
    			'edit_posts' => 'edit_atelierposts',
    			'edit_others_posts' => 'edit_others_atelierposts',
    			'publish_posts' => 'publish_atelierposts',
    			'read_post' => 'read_atelierpost',
    			'read_private_posts' => 'read_atelierposts',
    			'delete_post' => 'delete_atelierpost',
    		),
    		'has_archive' => true
        );
    
        /* Register the music album post type. */
        register_post_type( 'ateliers_lisaa_labo', $ateliers_lisaa_args );
    
    }
    
    ?>

    http://wordpress.org/extend/plugins/members/

Viewing 15 replies - 1 through 15 (of 15 total)
  • What’s the code you’re using to map meta caps?

    Since you’re not allowing WordPress to do this for you, you need to roll your own meta cap functionality (assuming you haven’t written this code already). See:
    http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types

    Thread Starter Gregoire Noyelle

    (@aglekis)

    Thanks Justin for your answer!
    In the code of the preceding message I post the capabilies code.

    Here is the code:

    'capabilities' => array(
    			'edit_post' => 'edit_atelierpost',
    			'edit_posts' => 'edit_atelierposts',
    			'edit_others_posts' => 'edit_others_atelierposts',
    			'publish_posts' => 'publish_atelierposts',
    			'read_post' => 'read_atelierpost',
    			'read_private_posts' => 'read_atelierposts',
    			'delete_post' => 'delete_atelierpost',
    		),

    Am I right?

    I want to say to you a big thank you for you book WordPress Plugin Developpement. I really enjoy and learn a lot!

    Thread Starter Gregoire Noyelle

    (@aglekis)

    Sorry, Justin
    I think I just found the answer. I need to add the code like in your article in this part: Mapping the meta capabilities
    Am I right?

    Yes, you have to map the edit_post, read_post, and delete_post meta capabilities for your post type. These are not capabilities that you add to a role.

    Also see the map_meta_cap argument here:
    http://codex.wordpress.org/Function_Reference/register_post_type

    I haven’t played around with it much, but it might be easier to do than rolling your own.

    Thread Starter Gregoire Noyelle

    (@aglekis)

    Great thanks to you 🙂
    I will try. I use more and more your plugin.

    If you need to translate in french, send me a .pot and I’ll make it for you

    The plugin is currently getting an update. If you have a little extra time, test out the beta version and leave some feedback here:
    http://justintadlock.com/archives/2011/06/01/members-plugin-beta-testing

    I wouldn’t recommend translating the current version. Wait for version 0.2 to come out because there are tons of text string changes.

    Thread Starter Gregoire Noyelle

    (@aglekis)

    Ok Justin. I will try it on my test website which already have the 0.1 version and give you my feedback.
    And for the translation, I will wait.
    Thanks !!

    Thread Starter Gregoire Noyelle

    (@aglekis)

    Justin, It works great now. Thanks again for your help.

    I’m trying to get capabilities working on custom post type called case studies so I can use the membership plugin. I’t doesn’t like my code but I can’t see where I’m going wrong. Any ideas?

    add_action('init', 'casestudy_register');
    add_action("admin_init", "admin_init");
    add_action('save_post', 'save_details');
    
    register_taxonomy("casestudytype", array("casestudy"), array("hierarchical" => true, "label" => "Case Study Type", "singular_label" => "Case Study Type", "rewrite" => true));
    
    function casestudy_register() {
    
    	$labels = array(
    		'name' => _x('Case Studies', 'post type general name'),
    		'singular_name' => _x('Case Study', 'post type singular name'),
    		'add_new' => _x('Add New', 'Case Study'),
    		'add_new_item' => __('Add New Case Study'),
    		'edit_item' => __('Edit Case Study'),
    		'new_item' => __('New Case Study'),
    		'view_item' => __('View Case Study'),
    		'search_items' => __('Search Case Study'),
    		'not_found' =>  __('Nothing found'),
    		'not_found_in_trash' => __('Nothing found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => array('slug'=> 'case-studies'),
    		'hierarchical' => true,
    		'menu_position' => null,
    		'has_archive' => 'case-studies',
    		'supports' => array('title','editor','thumbnail'),
    		'capability_type' => 'casestudy',
    			'capabilities' => array(
    				'publish_posts' => 'publish_casestudies',
    				'edit_posts' => 'edit_casestudies',
    				'edit_others_posts' => 'edit_others_casestudies',
    				'delete_posts' => 'delete_casestudies',
    				'delete_others_posts' => 'delete_others_casestudies',
    				'read_private_posts' => 'read_private_casestudies',
    				'edit_post' => 'edit_casestudy',
    				'delete_post' => 'delete_casestudy',
    				'read_post' => 'read_casestudy',
    			)
    	  ); 
    
    	register_post_type( 'casestudy' , $args );
    }
    Thread Starter Gregoire Noyelle

    (@aglekis)

    You need to add your new capabilities on the Members panel. Look at my screenshoot here. The red arrows show my capabilities.

    Hi Grégoire, I’m trying, obviously this is done by adding them to the function, but adding the following code to the function removes case studies totally from WordPress, I have no idea why.

    'capabilities' => array(
    				'publish_posts' => 'publish_casestudies',
    				'edit_posts' => 'edit_casestudies',
    				'edit_others_posts' => 'edit_others_casestudies',
    				'delete_posts' => 'delete_casestudies',
    				'delete_others_posts' => 'delete_others_casestudies',
    				'read_private_posts' => 'read_private_casestudies',
    				'edit_post' => 'edit_casestudy',
    				'delete_post' => 'delete_casestudy',
    				'read_post' => 'read_casestudy',
    			)
    Thread Starter Gregoire Noyelle

    (@aglekis)

    Ok .Sorry (Dan?) for my screenshoot. There is an error. For this role

    'edit_post' => 'edit_casestudy',
    'delete_post' => 'delete_casestudy',
    'read_post' => 'read_casestudy',

    You have to add capabilies like describe in this article and never add to any role in the Members panel.

    Beautiful! Thank you all for your back-and-forth in this thread. Helped solve a huge roadblock for me!

    Thread Starter Gregoire Noyelle

    (@aglekis)

    @thecorkboard Cool! you’re welcome!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Members] Custom post type and edit_other_posts capabilities’ is closed to new replies.