Support » Plugin: Groups 404 Redirect » Does not redirect on individual posts

  • Resolved joelworsham


    I have it set to redirect to a page by ID. It works when trying to view pages that have been restricted individually. But when viewing a post that belongs to a category which is restricted, it does not redirect, it just gives me a 404.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter joelworsham


    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.

    Thread Starter joelworsham


    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 4 years, 6 months ago by joelworsham.
    Thread Starter 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!


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Does not redirect on individual posts’ is closed to new replies.