2016-09-23 41 views
0

在woocommerce membership插件中有一個名爲class-wc-memberships-restrictions.php的文件,該文件具有以下類和構造函數,並且該構造函數具有大量過濾器,但是我想從此過濾器中刪除此過濾器我的孩子主題functions.php文件woo商業會員插件

如何從子主題的functions.php文件中刪除此過濾器

class WC_Memberships_Restrictions { 

public function __construct() { 

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

} 
+1

檢查['remove_filter()'](https://codex.wordpress.org/Function_Reference/remove_filter),但您需要知道如何初始化WC_Memberships_Restrictions。 – helgatheviking

+0

如何初始化在functions.php文件中的插件類 –

回答

2

我發現我曾經工作過的成員的舊副本。通過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'); 

但如果您的內容不侷限於(後/頁的設置可能...也許一個全球性的選擇,我不記得了)你不需要這麼做。

+0

真棒你保存了我的生活 –

+0

有沒有一種方法來創建自定義循環來顯示當前用戶的受限內容列表(鏈接的文章或頁面)。 –

+0

這是一個單獨的問題。 – helgatheviking