0

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

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.