the_content filter causing plugin conflicts

Hi there, we use Groups with the theme WPLMS. We were having a few errors in quiz reporting and some text fields on the site. narrowed it down to the Groups plugins and specifically the following line of code.

wp-content\plugins\groups\lib\access\class-groups-post-access.php

Line 102 add_filter( ‘the_content’, array( __CLASS__, ‘the_content’ ), 1 );

Commented this line out and everything works again.

Could you double check that this code is correct and if it is could you let us know what might be affected by commenting it out?

Thanks,
Lawrence

Posted in

Comments

5 responses to “the_content filter causing plugin conflicts”

  1. Lawrence Avatar

    Ended up having to parse the URL to get something actionable. Hope this helps someone else!

    add_filter( ‘groups_post_access_the_content_apply’, ‘my_groups_post_access_the_content_apply’, 10, 2 );

    function my_groups_post_access_the_content_apply( $apply, $output ) {
    global $post;
    global $wp;
    $current_url = home_url(add_query_arg(array(),$wp->request));

    if (strpos($current_url, ‘course-results’) !== false) {
    $apply = false;
    }
    return $apply;
    }

    1. Perfect, thanks for sharing that Lawrence!

  2. Lawrence Avatar
    Lawrence

    Thanks Kento, I had disabled protecting access to everything and still had the problem until I commented out that line. The error happens when submitting the quiz. the_content filter the data uploaded tot he database.

    I’ll see what I can do with the filter and post my results.

    1. Thanks Lawrence, yes please let me know how it turns out.

  3. Hi Lawrence,

    By disabling this filter, you could expose protected content to those who should not be able to access it.

    There are two direct solutions, one is to simply disable protecting access to the quiz content, you can do that under Groups > Options (assuming a plugin or theme you mention creates a post type for the quizzes).

    The second option it to rather use the groups_post_access_the_content_apply filter to determine whether the content filter should be applied to a particular instance based on the global $post object.

    add_filter( 'groups_post_access_the_content_apply', 'my_groups_post_access_the_content_apply', 10, 2 );

    function my_groups_post_access_the_content_apply( $apply, $output ) {
    global $post;
    // @todo implement your checks here and determine $apply to be true or false depending on whether the content should be filtered based on access restrictions
    return $apply;
    }

    Cheers

Share