Skip to content

Instantly share code, notes, and snippets.

@artpi
Last active December 25, 2020 08:07
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 artpi/66b5689d9789a7c1c180f36139400e6a to your computer and use it in GitHub Desktop.
Save artpi/66b5689d9789a7c1c180f36139400e6a to your computer and use it in GitHub Desktop.
Private podcast on WordPress
// put that in functions.php in your theme
add_filter( 'the_content', $content, 'private_podcast', 10, 1 );
function private_podcast( $content ) {
if( has_category( 'podcast' ) && ! has_access() ) {
return "This is a private podcast. Please subscribe here";
}
return $content;
}
function has_access() {
global $_GET;
return in_array( $_GET['token'], ['token1', 'token2']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment