Skip to content
Advertisement

WooCommerce membership plugin

In WooCommerce membership plugin there is a file with name class-wc-memberships-restrictions.php this file have the following class and constructor and that constructor have lots of filters, but I want to remove this filter from my child theme functions.php file

How can I remove this filter from child theme functions.php file

class WC_Memberships_Restrictions {

public function __construct() {

add_filter( 'the_content',   array( $this, 'restrict_content' ) );

}

Advertisement

Answer

I found an old copy of Memberships that I had worked on once. An “instance” of the plugin is loaded via the wc_memberships() function and the restrictions class is loaded into the $this->restrictions class variable. See the main file.

In your functions.php you’d do the following to disable it.

function so_39668842_remove_membership_restriction(){
    remove_filter( 'the_content', array( wc_memberships()->restrictions, 'restrict_content') );
}
add_action( 'wp_head', 'so_39668842_remove_membership_restriction' );

Though if your content isn’t restricted (post/page settings probably… maybe a global option, I don’t remember) you don’t need to do this.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement