Skip to content
Advertisement

Restrict content to those who purchased a Woocommerce product

I’m trying to restrict content on the page via shortcode for those who purchased a particular woocommerce product. I tried using the code below but it’s not working – shortcode [wcr pid="78] this is some text [/wcr] is just being outputted on the page without hiding the content. Woocommerce has a function for restricting content like this.

JavaScript

Advertisement

Answer

There is some mistakes in your code and in the way to use the shortcode too

1) The code:

JavaScript

2) the shortcode usage:

  • In a text editor: [wcr pid="78"] this is some text [/wcr].
  • Inside php code: echo do_shortcode( '[wcr pid="78"] this is some text [/wcr]' );.

Code goes in functions.php file of your active child theme (active active theme). Tested and works.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement