• Resolved peter8nss

    (@peter8nss)


    I’d like to be able to display a denial message that depended on what was accessed. I can see that there is a filter content_control/restricted_post_content which looks like a great candidate for doing this. That filter helpfully makes the restriction available so I could have different messages based on that, but it would be useful to know the post that the message was being generated for too. As far as I can see global $post is not available, so would it be possible to provide the post as an additional argument on the filter?

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

    (@danieliser)

    @peter8nss – Hmm, first get_the_ID() should work, as we do this within the restriction checks there as well,

    We can definitely add that, I though we had already done work to add that, remember doing so but don’t see the commit logs, so either I thought it through previously or even coded it but didn’t get it committed for some reason.

    Currently I think you have another option too, make multiple restrictions, similar but different based on content, just update the rules on each based on which tag your filtering content on for example.

    Future 3rd option, I’ve been working on v2.1 which will likely also allow using presaved block patterns, and since we have block controls that can selectively target based on post info as well, you could also build it that way.

    Let me know about get_the_ID().

    Thread Starter peter8nss

    (@peter8nss)

    Thanks for the prompt response. I’d already tried get_the_ID() and it is returning false. Hence, my question.

    This occurs when I’m retrieving calendar data (using plugin The Event Calendar) so it may be some oddity related to how that plugin is working rather than the Content Control plugin.

    Passing the post to the filter would be nice and would give me post level granularity for controlling the messaging. However. I appreciate that you may have other developments that are higher priority.

    Plugin Author Daniel Iser

    (@danieliser)

    @peter8nss – Can you give me some sample code for what your trying, will work out a solution for you really quick.

    Thread Starter peter8nss

    (@peter8nss)

    I think the reason I’m not getting any post id is because the restriction is triggering from “filter_the_content_if_restricted” rather than “restrict_query_posts” (i.e. filters on “the_content” rather than “the_posts”).

    The scenario I’m working on is securing the information sent out in ical messages (from The Event Calendar plugin). However, I think I’m probably better to use the hooks in The Event Calendar for this rather than abuse the design of Content Control.

    Thanks again for your help on this.

    Plugin Author Daniel Iser

    (@danieliser)

    Hmm, filter_the_content_if_restricted should theoretically be called from within the_content filter, as such the global $post should be set properly.

    I wonder if TEC is doing something different there calling the_content generically without setting global first.

    You can do that in code, simply calling apply_filters( 'the_content', $content ) doesn’t care about global states or doing it right.

    That would be my guess, they just apply generic content filters, instead of setting globals for per post filtering.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom denial messages’ is closed to new replies.