Removing The Content Restriction Metabox

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:
https://codeable.io/developers/restrict-content-pro/

When using Restrict Content Pro, the "Restrict this Content" meta box is automatically loaded on all public registered post types, but sometimes you may want to remove it from certain post types. This tutorial will walk you through the process of removing the meta box from a specific post type.

For example, to remove the meta box from the "books" post type, use this:

  <?php
  /**
  * Remove the "restrict this content" meta box from the "books" post type.
  *
  * @param array $post_types List of post types the meta box should not be added to.
  *
  * @return array
  */
  function pippin_exclude_post_types_from_rcp( $post_types ) {
  // We do NOT want the meta box displayed on the "books" post type.
  $post_types[] = 'books';
   
  return $post_types;
  }
   
  add_filter( 'rcp_metabox_excluded_post_types', 'pippin_exclude_post_types_from_rcp' );

An array of post types is passed to the filter with the $post_types variable. All we need to do is add the name of our post type to the array and then return the modified array.

You can set as many post types as you want to be excluded. To remove the meta box from both "books" and "page", use this:

  <?php
  /**
  * Remove the "restrict this content" meta box from the "books" and "page" post types.
  *
  * @param array $post_types List of post types the meta box should not be added to.
  *
  * @return array
  */
  function pippin_exclude_post_types_from_rcp( $post_types ) {
  // We do NOT want the meta box displayed on the "books" or "page" post types.
  $post_types[] = 'books';
  $post_types[] = 'page';
   
  return $post_types;
  }
   
  add_filter( 'rcp_metabox_excluded_post_types', 'pippin_exclude_post_types_from_rcp' );

You can continue adding as many post types as you need. It's that simple!

Please note: All of these examples serve as a guideline and are here for your convenience. We do not provide support for troubleshooting or modifying these and we do not provide support for any custom development. If you need help with any of these examples, consider hiring a developer.

Powered by Zendesk