79795709

Date: 2025-10-21 10:31:49
Score: 1
Natty:
Report link

I know this is an old thread, but there is still no "create_post" capability (I wonder why?) and I needed this functionality as well.

What I want: I create a single post for specific users with a custom role and then only let them edit that post.

This is what works for me:

'edit_posts' => false : will remove the ability to create posts, but also the ability to edit/update/delete

'edit_published_posts' => true : this will give back the ability to edit and update, but no to create new posts (so there will be no "Add post" button)

The whole function & hook:

function user_custom_roles() {

remove_role('custom_role'); //needed to "reset" the role

add_role(
        'custom_role',
        'Custom Role',
        array(
            'read' => true,
            'delete_posts' => false,
            'delete_published_posts' => false,
            'edit_posts' => false, //IMPORTANT
            'edit_published_posts' => true, //IMPORTANT
            'edit_others_pages' => false,
            'edit_others_posts' => false,
            'publish_pages' => false,
            'publish_posts' => false,
            'upload_files' => true,
            'unfiltered_html' => false
        )
    );
    
}
add_action('admin_init', 'user_custom_roles');  
Reasons:
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (0.5): why?
  • Whitelisted phrase (-1): works for me
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: marioline