/**
* Only allowing the customer and admin user role to view the product images
*
* @param $value
*
* @return bool
*/
function woocommerce_product_get_image_id_callback( $value ) {
global $current_user;
if (
in_array( \'customer\', (array) $current_user->roles )
|| in_array( \'administrator\', (array) $current_user->roles )
) {
return $value;
} else {
return false;
}
}
add_filter( \'woocommerce_product_get_image_id\', \'woocommerce_product_get_image_id_callback\', 10, 1 );
复制上述代码并将其粘贴到函数中。子主题的php文件