• Resolved lukiano880

    (@lukiano880)


    Hi.

    I created a custom post type with a custom taxonomy (I used ACF to create them).
    Content restriction does not work.
    I set the redirect to the home page if it is a normal page or if it is a custom post.
    If it is a normal page it works fine, but if it is a custom post, no restriction happens.
    It doesn’t work either with custom post archive, custom taxonomy, selected custom post…

    WordPress 3.3.1
    Content Control 2.0.9

    Plugins installed:
    Content Control
    ACF

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    @lukiano880 – Hmm, I was testing with ACF on a separate issue the other day, can’t say I ran into this but I’m happy to help.

    The first thing to do is check your Content Control logs, available on the settings page). If you see missing rule notices it likely means something on your site is running post queries before your post types are officially registered. Since we filter post queries, this is forcing our rules to be generated before your types are ready.

    You can try this fix here, which will prevent our query filters from running until much later. If you don’t see any adverse side effects its probably safe to leave it.

    That said I’ll do some digging and see if maybe there is a more elegant solution.

    add_filter( 'content_control/query_filter_init_hook', function () {
        return 'init'; // Try setup_theme, after_theme_setup, init or wp_loaded
    } );
    • This reply was modified 1 year, 5 months ago by Daniel Iser.
    Plugin Author Daniel Iser

    (@danieliser)

    @lukiano880 – Just retested and verified some issues, patches incoming (v2.0.10) later today.

    You can test the fix now by adding the following:

    remove_filter( 'the_posts', [ \ContentControl\plugin('Frontend\Restrictions\QueryPosts'), 'restrict_query_posts' ], 10, 2 );
    
    add_action( 'init', function () {
    	add_filter( 'the_posts', [ \ContentControl\plugin('Frontend\Restrictions\QueryPosts'), 'restrict_query_posts' ], 10, 2 );
    }, 999 );

    If that solves it for you as well, please take a moment to?rate & review?the plugin and or support to spread the word.

    PS after the update I’d remove that to ensure your using the latest & most reliable setup.

    • This reply was modified 1 year, 5 months ago by Daniel Iser. Reason: Add testable code solution
    • This reply was modified 1 year, 5 months ago by Daniel Iser.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Doesn’t work with custom post type’ is closed to new replies.