Title: create_posts capability not mapped.
Last modified: August 22, 2016

---

# create_posts capability not mapped.

 *  Resolved [3pepe3](https://wordpress.org/support/users/3pepe3/)
 * (@3pepe3)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/create_posts-capability-not-mapped/)
 * Hello,
 * I’m trying to map the capability create_posts for posts, pages and custom posts.
 * So I’m doing this :
 *     ```
       function fix_capability_create(){
       	$post_types = get_post_types( array(),'objects' );
       	foreach ( $post_types as $post_type ) {
       		$cap = "create_".$post_type->name;
       		$post_type->cap->create_posts = $cap;
       	}
       }
       add_action( 'init', 'fix_capability_create',100);
       ```
   
 * In the “user role editor” I can’t see the new cap create_posts or “create_”.$
   post_type->name (create_books).
 * In user role editor if I add the cap create_books then everything works like 
   a charm… but this is a tedious task for each projects and more when we have several
   post_types created by cpt-onomies.
 * Any idea ? I was trying “map_meta_cap( $cap, 1);” or ” $role->add_cap( $cap );”(
   yes, $role was defined) but without success.
 * thanks in advance.
    Pepe
 * [https://wordpress.org/plugins/user-role-editor/](https://wordpress.org/plugins/user-role-editor/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [3pepe3](https://wordpress.org/support/users/3pepe3/)
 * (@3pepe3)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/create_posts-capability-not-mapped/#post-5307601)
 * uppppppppppppp….. actually I forgot to activate the theme.
    So the capability
   is mapped and working as expected.
 * code:
 *     ```
       function fix_capability_create(){
       	$post_types = get_post_types( array(),'objects' );
       	foreach ( $post_types as $post_type ) {
       		$cap = "create_".$post_type->name;
       		$post_type->cap->create_posts = $cap;
       		map_meta_cap( $cap, 1);
       	}
       }
       add_action( 'init', 'fix_capability_create',100);
       ```
   
 *  the action was init and not admin_init or anything else because init at priority
   100 prevents the display of “add new” on admin bar, sidebar, etc (in all the 
   wp interface).
 * thanks
    Pepe
 *  Thread Starter [3pepe3](https://wordpress.org/support/users/3pepe3/)
 * (@3pepe3)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/create_posts-capability-not-mapped/#post-5307606)
 * So i will close the topic.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘create_posts capability not mapped.’ is closed to new replies.

 * ![](https://ps.w.org/user-role-editor/assets/icon-256x256.jpg?rev=1020390)
 * [User Role Editor](https://wordpress.org/plugins/user-role-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-role-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-role-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/user-role-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-role-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-role-editor/reviews/)

## Tags

 * [capability](https://wordpress.org/support/topic-tag/capability/)
 * [map](https://wordpress.org/support/topic-tag/map/)

 * 2 replies
 * 1 participant
 * Last reply from: [3pepe3](https://wordpress.org/support/users/3pepe3/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/create_posts-capability-not-mapped/#post-5307606)
 * Status: resolved