WooCommerce会员插件


WooCommerce membership plugin

在WooCommerce会员插件中有一个名为class-wc-members -restrictions.php的文件,该文件有以下类和构造函数,构造函数有很多过滤器,但我想从我的子主题函数。php文件中删除此过滤器

如何从子主题函数。php文件中删除此过滤器

class WC_Memberships_Restrictions {
public function __construct() {
add_filter( 'the_content',   array( $this, 'restrict_content' ) );
}

我发现了一份我曾经做过的会员资格的旧副本。插件的"实例"通过wc_memberships()函数加载,限制类加载到$this->restrictions类变量中。请参阅主文件。

在您的functions.php中,您将执行以下操作来禁用它。

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' );

如果你的内容不受限制(帖子/页面设置可能…也许是一个全局选项,我不记得了)你不需要这样做。