Patreon WordPress - how to lock any part of your Website

How to lock any section, page, type of content, or template section through the code


(If you are using Patron Plugin Pro, use the code at +Patreon Pro - how to lock any part of your Website  instead!)

Its possible to gate any section of your WordPress site, a widget, some content in widget, some piece of meta value shown in the header, footer, or even remote embedded content displayed somewhere by using the code below.

This code can be put into header, or, for example in the theme element that shows webcomics in headers or widgets.

How to use the code:

1 - Just copy/paste the below code into your theme file where you want to gate content.
2 - Make sure the code is not pasted inside other <?php ?> tags. 
3 - Replace 7 with the $ value that you want to gate the content with
4 - Put your patron only content where it says “*** Put your patron-only content here! ***” by replacing that text.
5- Done!

<?php

  $patreon_custom_gate_level = 7; // Replace 7 with the $ value which you want to gate this content with - without the $ sign

  if ( $patreon_gate = Patreon_Frontend::gate_custom_content( $patreon_custom_gate_level ) ) {
      echo $patreon_gate;
  }
  else {
      ?>
         *** Put your patron-only content here! ***
      <?php
  }
        
?>

(The older version of this document can be found at +Patreon WordPress - how to lock any part of your Website (old version))