• Resolved authentico

    (@authentico)


    I created a custom post type, which I’ll be stuffing manually with posts using a hook (aka. it will grab content from a form submitted in WPForms, and will insert the content into my custom pod).

    I want to disable the “Add New” functionality in the backend, so that the “Add New” button doesn’t appear anywhere (in the side menu, or on the list view page for the custom post type).

    I see this can be accomplished using:

    register_post_type('custom_post_name', array(
        'capabilities' => ['create_posts' => false],
        'map_meta_cap' => true,
    ));

    But I don’t see an equivalent in the PODS editor.

    Is there a way I can disable the “create_posts” capability?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter authentico

    (@authentico)

    Note: if I try to use that code, it overwrites the custom post type that was generated by Pods.

    Is there a way I can grab the $args value that Pods generated for my custom_post_type, so I can change that single capability?

    Thread Starter authentico

    (@authentico)

    Found a solution. Code proposed by ChatGPT works:

    function modify_pods_custom_post_type_args($args, $post_type) {
        // Check if the post type is the one created by Pods plugin that you want to modify
        if ($post_type === 'my_custom_post_type') {
            // Modify the 'create_posts' capability to false
            $args['capabilities']['create_posts'] = false;
        }
        return $args;
    }
    
    add_filter('register_post_type_args', 'modify_pods_custom_post_type_args', 10, 2);
    
    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Appreciate you providing this feedback, I went ahead and added the ability to disable the Add New forms to Pods 3.0.2 which will go out soon.

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Pods 3.0.2 is now out with this new addition. It’s in the Edit Pod > Advanced tab.

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

The topic ‘How to disable ‘create_posts’ capability?’ is closed to new replies.