To shed more light on this issue, there is a conflict. In the method Groups_Restrict_Categories::user_can_read(), which is used to determine if we should redirect or not when viewing something. Part of this function is getting the terms of the current post, $terms = get_the_terms( $post_id, $taxonomy );. The issue is that in this same class, there’s a method Groups_Restrict_Categories::list_terms_exclusions(), which generically disallows retrieving restricted terms. So the conflict:
user_can_read() gets the posts terms and sees if they’re disallowed
list_terms_exclusions() prevents user_can_read() from getting the post terms to see if disallowed.
The current, temporary fix, was to add remove_filter( 'list_terms_exclusions', array( 'Groups_Restrict_Categories', 'list_terms_exclusions' ) ); right before user_can_read() get the terms, and then add it back after.
Please try to fix this before the next release, I would much appreciate it.
Thanks for the free plugin guys, it is really great.
OH, also, I had to add wp_cache_delete($post_id, "{$taxonomy}_relationships"); right before retrieval because they were previously cached is nonexistent due to list_terms_exclusions().
-
This reply was modified 9 years, 1 month ago by
joelworsham.
Hi Joel,
Thanks for pointing out the issue and sorry for the late reply. I’ve checked this and although your solution is pointing in the right direction I’ve adopted a slightly different approach using wp_get_object_terms() instead of get_the_terms() and deleting the cache entry.
You’ll see an update available for Groups Restrict Categories shortly.
Again many thanks for your thoughts on the issue!
Cheers