I am trying to add capabilities for subscriber role to add/edit/delete the custom post.

function add_custom_caps() {
    // gets the subscriber role
    $role = get_role( 'subscriber' );

    // This only works, because it accesses the class instance.
    // would allow the subscriber to edit others' posts for current theme only
     $role->add_cap( 'read' );
     $role->add_cap( 'read_post');
     $role->add_cap( 'read_private_post' );
     $role->add_cap( 'edit_post' );
     $role->add_cap( 'edit_others_post' );
     $role->add_cap( 'edit_published_post' );
     $role->add_cap( 'publish_post' );
     $role->add_cap( 'delete_others_post' );
     $role->add_cap( 'delete_private_post' );
     $role->add_cap( 'delete_published_post' );
add_action( 'admin_init', 'add_custom_caps'); 

I placed the code snippet provided in this ticket reply How to allow custom post type (add, edit, delete) for subscriber users in wordpress

Still, I am not able to add/edit/delete post as a subscriber?

Please, can someone help me. Thanks in advance

  • how do you create the CPT ? do you use "map_meta_cap" ? – mmm Oct 10 '17 at 12:56
  • add_cap is used @mmm – Himani Oct 10 '17 at 13:02
  • Well, you're add capabilities to edit the normal post post type. What is your custom post type? – disinfor Oct 10 '17 at 17:12
  • custom post type is 'dpsweb' @disinfor – Himani Oct 11 '17 at 5:04
  • Possible duplicate of Capabilities and Custom Post Types – disinfor Oct 11 '17 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.