Overview
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.
Parameters
$rules
: An array of post types and their access control rules
Examples
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', 'Tag Two' ), // Array of required tags. Must use tag IDs if the CRM uses tag IDs
'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?
Let us know if you liked the post. That’s the only way we can improve.