在 BuddyBoss 配置文件中有条件地加载文档

问题描述 投票:0回答:0

我正在尝试让当前用户的文档只能由当前用户和管理员访问。

我目前正在尝试添加过滤器,当您不在自己的个人资料中时,您将看不到文档。然而,文件仍在显示......

function debug($data) {
    $output = $data;
    if (is_array($output))
        $output = implode(',', $output);

    echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
}

function document_screen_restrict() {
        if ( bp_is_my_profile() != 1 ) {
            debug("not my documents, SHOULD NOT SEE");
            add_filter("document_screen",'__return_false');
            debug(did_action( 'document_screen' ));
            return;
        }else{
            debug("My documents, SEE");
            remove_filter("document_screen",'__return_false');
            debug(did_action( 'document_screen' ));

        }
}

add_action('wp','document_screen_restrict',10);
php wordpress buddypress buddyboss
© www.soinside.com 2019 - 2024. All rights reserved.