This filter lets you apply WP Fusion’s access controls to an entire post type.

To use the code examples below, add them to your active theme’s functions.php file.


  • $rules: An array of post types and their access control rules

#Rule properties

The array properties for the access rules are the same as those saved on an individual post. They are:

  • lock_content: (bool) The user must be logged in to access the content
  • allow_tags: (array) The user must have at least one of the specified tags to access the content. Tag IDs must be used if the CRM uses tag IDs. If you’re not sure, use wpf_get_tag_id( $name ) to get the ID.
  • allow_tags_all: (array) The user must have all of the tags to access the content
  • allow_tags_not: (array) The user must have none of the tags to access the content
  • redirect: (int) A post ID to redirect the user to if access is denied. Leave blank to display the Restricted Content Message
  • redirect_url: (string) Optionally specify a remote URL to redirect the user to if access is denied. Will take priority over redirect


The example below will protect a custom post type with slug my_type and redirect the user if they don’t have the required tags.

function wpf_post_type_rules( $rules ) {

	$rules['my_type'] = array(
		'lock_content'   => true,
		'allow_tags'     => array( 'Tag One' ),              // Array of required tags (any). Must use tag IDs if the CRM uses tag IDs
		'allow_tags_all' => array( 'Tag Two', 'Tag Three' ), // Array of required tags (all)
		'allow_tags_not' => array( 'Payment Failed' ),       // Array of required tags (not)
		'redirect'       => 123,                             // Post ID to redirect to
		'redirect_url'   => 'https://example.com/',          // OR enter a URL (overrides post ID redirect)

	return $rules;


add_filter( 'wpf_post_type_rules', 'wpf_post_type_rules' );

Was this helpful?