Created
February 13, 2014 20:57
-
-
Save woogist/8983691 to your computer and use it in GitHub Desktop.
Add the following to your theme's functions.php to show product documents only for logged in users. Note that this is a very simple example, and could be expanded upon to show documents only for a particular user role, only for particular products, anything! http://www.woothemes.com/products/product-documents/
This file contains 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