Change capability type of post type registered by plugin

@PieterGoosen is cool, and still awake like me and answering like boss.

To simplify his code and make it work to this specifically without a bunch of junk on your page:

/**
 * Pieter Goosen writes awesome code
 */
add_filter( 'register_post_type_args', 'change_capabilities_of_the_custom_css_js_posttype' , 10, 2 );

function change_capabilities_of_the_custom_css_js_posttype( $args, $post_type ){

 // Do not filter any other post type
 if ( 'custom-css-js' !== $post_type ) {

     // Give other post_types their original arguments
     return $args;

 }

 // Change the capability_type of the "custom-css-js" post_type
 $args['capability_type'] = 'manage_options';

  // Give the custom-css-js post type it's arguments
  return $args;

}

The plugin you have chosen is written in a broad way. It has some insecurities.

Leave a Comment