Home Forums Backend Issues (wp-admin) Restricting Access To One Post Type But Not All Reply To: Restricting Access To One Post Type But Not All

  • You could create a custom capability and update capabilities for the roles you want to have access to your post type.

    For example, in ACF’s post type creation screen go to the permissions tab. Once there click on “Rename Capabilities”. Add a singular and plural value, in this example I named them “test” and “tests” respectively (I suggest you use something that makes more sense).

    As a test I went ahead and added access to a post type to only the administrator role. In your functions.php file add the following code:

    add_action( 'init', function(){
        $role_object = get_role( 'administrator' );
        // add $cap capability to this role object
        $role_object->add_cap( 'YOUR_CAP_VALUE' );
        $role_object->add_cap( 'edit_YOUR_CAP_VALUE' );
        $role_object->add_cap( 'read_YOUR_CAP_VALUE' );
        $role_object->add_cap( 'delete_YOUR_CAP_VALUE' );
        $role_object->add_cap( 'edit_YOUR_PLURAL_CAP_VALUE' );
        $role_object->add_cap( 'edit_other_YOUR_PLURAL_CAP_VALUE' );
        $role_object->add_cap( 'publish_YOUR_PLURAL_CAP_VALUE' );
        $role_object->add_cap( 'read_private_YOUR_PLURAL_CAP_VALUE' );
        $role_object->add_cap( 'delete_YOUR_PLURAL_CAP_VALUE' );
        $role_object->add_cap( 'create_YOUR_PLURAL_CAP_VALUE' );

    Make sure to replace both YOUR_CAP_VALUE and YOUR_PLURAL_CAP_VALUE to whatever you pick as the capability names. So in my example they would be “test” and “tests”.

    I suggest checking out the WP documentation on creating post types and the capabilities if you would like more granular control.