caseproof / members

Members WordPress plugin.
GNU General Public License v2.0
81 stars 35 forks source link

Content blocker incompatible with bricks builder #121

Open JUVOJustin opened 8 months ago

JUVOJustin commented 8 months ago

I noticed that the content blocker feature is incompatible with the bricks builder. This is most likely since it does not send its content through the_content.

However, there is a bricks filter one could utilize to achieve the same:

// Add bricks support to members
add_filter( 'bricks/frontend/render_data', function($content, $post, $area) {

    // Make sure members plugin is active
    if (!function_exists('members_content_permissions_protect')) {
        return $content;
    }

    if ($area != 'content') {
        return $content;
    }
    return members_content_permissions_protect($content);
}, 95, 3);

I did test this and i works. There might be some edge cases I am currently not aware of. The filter is documented here: https://academy.bricksbuilder.io/article/filter-bricks-frontend-render_data/

I would love to see this merged into the plugin. If I get some subtle hint where to best add the code, i will happily provide a pull request.