Hide some document categories for non members (woocommerce product docs) (1 post)

  1. maxamaxa2
    Posted 1 year ago #


    Im looking for something that I think is quite simple but I just cant figure out how to do it.
    So I have woothemes plugin "Product Documents" and would like to hide some of the documents for people that is not logged in.
    Lets say that I have a document category called "Service" and one called "Secret" that I want to only show when logged in, how would I implement that?
    I have a code to hide all, but how do I only hide some categories/documents?

    This is the code I have for functions.php (from woothemes page)

    add_filter( 'wc_product_documents_get_sections', 'show_documents_only_for_logged_in_users', 10, 3 );
     * Don't return document sections unless there is a logged in user.
     * @param array $sections array of sections
     * @param WC_Product_Documents_Collection $collection the collection object
     * @param boolean $include_empty whether to include empty sections in the result
     * @return array sections for display
    function show_documents_only_for_logged_in_users( $sections, $collection, $include_empty ) {
        // this check can be made as specific (by user role, etc) as desired
        if ( ! get_current_user_id() ) {
            return array();
        return $sections;

    Thanks a lot in advance!
    Best regards

Topic Closed

This topic has been closed to new replies.

About this Topic