Last active
August 22, 2017 16:32
-
-
Save woogist/9920046 to your computer and use it in GitHub Desktop.
Show Product Documents to Logged In Users Only - add everything after the <?php tag to the bottom of your theme's functions.php file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment