Forums

Make part of posts private (6 posts)

  1. namith.jawahar
    Member
    Posted 6 months ago #

    We often wish to provide some teaser content to visitors while keeping a part of the content reserved for registered users so that they will be lured to register on our site. This plugin helps you achieve exactly this. You will be able to mark a part of your post as private and the rest will be available to public and a register or login link will appear where your privatized content is supposed to appear. Once the user logs in they will be able to see the whole content (Great for membership sites). Now you can show off parts of your site to visitors and reserve parts for registered users.

    Download Link : http://smartlogix.co.in/wp-private/

  2. MichaelH
    moderator
    Posted 6 months ago #

  3. namith.jawahar
    Member
    Posted 6 months ago #

    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

  4. MichaelH
    moderator
    Posted 6 months ago #

    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; }
    
    }
    
    ?>
  5. MichaelH
    moderator
    Posted 6 months ago #

    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) &amp;&amp; ($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; }
    
    }
    
    ?>
  6. MichaelH
    moderator
    Posted 6 months ago #

    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) &amp;&amp; ($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; }
    
    }
    
    ?>

Reply

You must log in to post.

About this Topic