WordPress.org

Ready to get started?Download WordPress

Forums

Make part of posts private (7 posts)

  1. namith.jawahar
    Member
    Posted 5 years 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
    Member
    Posted 5 years ago #

  3. namith.jawahar
    Member
    Posted 5 years 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
    Member
    Posted 5 years 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
    Member
    Posted 5 years 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
    Member
    Posted 5 years 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; }
    
    }
    
    ?>
  7. namith.jawahar
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic