Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created June 17, 2013 16:01
Show Gist options
  • Save micahwave/5798047 to your computer and use it in GitHub Desktop.
Save micahwave/5798047 to your computer and use it in GitHub Desktop.
<?php
// somewhere in single.php
if( time_is_paid_content() ) {
if( time_is_paid_user() ) {
the_content();
} else {
echo 'Sorry, you must log in or sign up to view this content.'
}
} else {
the_content();
}
// somewhere else
function time_is_paid_content() {
// checks post meta to see if content is paid
}
function time_is_paid_user() {
$validate_user = function() {
// validates the users cookie, returns bool
};
if( function_exists( 'vary_cache_on_function' ) ) {
// im probably using this anonymous function wrong but you get the idea
vary_cache_on_function( "return $validate_user" );
}
return $validate_user;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment