Ugh, it doesn’t work. It just sticks the code in but the plugin doesn’t process.
Anyone know of a way to use this plugin at the theme leve?
Here’s my idea: I’m trying to create a stripped down version of the pluginn for functions.php. Here’s what I have right now:
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-->');
if($begin != $end) {
$prefix = substr($content,0,$begin);
if ( !$user_ID ) {
$message = get_option('wp_private_before_html').'<form action="'.get_bloginfo('url').'/wp/wp-login.php" method="post">
<table>
<tr><td align="left"><label>User Name</label></td><td>:</td><td><input type="text" name="log" id="log" value="'.wp_specialchars(stripslashes($user_login), 1).'" size="22" /></td></tr>
<tr><td align="left"><label>Password</label></td><td>:</td><td><input type="password" name="pwd" id="pwd" size="22" /></td></tr>
<tr valign="bottom"><td align="right" colspan="3">'.$linkback.'<input type="submit" value="Login" name="submit" class="submit_bt" /><input type="hidden" name="redirect_to" value="'.$_SERVER['REQUEST_URI'].'"/></td></tr>
</table></form>'.get_option('wp_private_after_html');
};
$suffix .= substr($content,$end,strlen($content));
return $prefix.$message.$suffix;
}
else {
return $content;
};
} else { return $content; };
};
function wp_private_install() {
if(!get_option('wp_private_login_form_enable')) { add_option("wp_private_login_form_enable", '1', '', 'yes'); }
if(!get_option('wp_private_linkback_enable')) { add_option("wp_private_linkback_enable", '1', '', 'yes'); }
if(!get_option('wp_private_before_html')) { add_option("wp_private_before_html", '<br /><div id="wp-private-box"><b>This is protected content. ', '', 'yes'); }
if(!get_option('wp_private_after_html')) { add_option("wp_private_after_html", '</b></div><br />', '', 'yes'); }
};
Then you wrap your content in <!--protected--> and <!--/protected--> in your theme files. But the thing I’m not managing to get it to do is run the $content through this function. Anyone know how to do that?