Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created April 17, 2018 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bekarice/d2406d4b6950ecbe25c12e379316313e to your computer and use it in GitHub Desktop.
Save bekarice/d2406d4b6950ecbe25c12e379316313e to your computer and use it in GitHub Desktop.
<?php // only copy if needed!
/**
* Filters the recipe to restrict it to non-members.
*
* @param string $recipe recipe content
* @return updated content
*/
function wpurp_woocommerce_memberships( $recipe ) {
if ( function_exists( 'wc_memberships_is_post_content_restricted' ) && wc_memberships_is_post_content_restricted() ) {
$recipe = '[wcm_restrict]' . $recipe . '[/wcm_restrict]';
}
return $recipe;
}
add_filter( 'wpurp_output_recipe' , 'wpurp_woocommerce_memberships' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment