Seems related…I just downloaded and checked what hidepost does…
This is the fun with wordpress…90% of the things you need will already be done and shared by someone else…I love wordpress for that..
Anyways I would recommend wp-private to newbies who just want the functionality shown above and hidepost to advanced users who wish for more control
You plugin is also very similar to http://alanwho.com/web-development/wordpress/plugins/protectcontent/ which is no longer supported, but was this code:
add_filter('the_content', 'protect_content');
function protect_content($content) {
global $current_user, $user_ID;
if (($current_user->id == 0) && ($user_ID == 0)){
$b = strpos($content, '<!--protectcontent-->');
$e = strpos($content, '<!--/protectcontent-->');
$pre = substr($content,0,$b);
$suf .= substr($content,$e,strlen($content));
return $pre.$suf;
} else { return $content; }
}
?>
And the plugin Hidethis had this code:
add_filter('the_content', 'hide_some_content');
function hide_some_content($content) {
global $current_user, $user_ID;
if (($current_user->id == 0) && ($user_ID == 0)){
$b = strpos($content, '<!--hidethis-->');
$e = strpos($content, '<!--/hidethis-->');
$pre = substr($content,0,$b);
$suf .= substr($content,$e,strlen($content));
return $pre.$suf;
} else { return $content; }
}
?>
Another wonder of WordPress–how many times coders come up with almost the same exact code.
Code from wp-private:
add_filter('the_content', 'protected_content');
function protected_content($content) {
global $current_user, $user_ID;
if (($current_user->id == 0) && ($user_ID == 0)){
$begin = strpos($content, '<!--protected-->');
$end = strpos($content, '<!--/protected-->');
$prefix = substr($content,0,$begin);
$message = '<div id="wp-private-box"><b>This is protected content. Please <a href="' . get_option('siteurl') . '/wp-login.php">Login</a> or <a href="' . get_option('siteurl') . '/wp-register.php">Register</a> for access.</b></div>';
$suffix .= substr($content,$end,strlen($content));
return $prefix.$message.$suffix;
} else { return $content; }
}
?>
Wp-Private no longer parses and then processes the post content to search for sections to block.
As of V1.3 I have added a bunch of customization options as well as moved the whole thing over to wordpress shortcode API.
Hope everyone find the new changes usefull..
Drop in a line at the wp-private tutorial site about your comments or suggestions.