@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().
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.
@peter8nss – Can you give me some sample code for what your trying, will work out a solution for you really quick.
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.
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.