• I have found this HIDETHIS plugin for WorPress made by Mark Edwards.

    Which hide all text of a post inside these tags <!–hidethis–>, <!–/hidethis–> when users are not logged.

    My primary usage of this script is for preventing youngster public access to posts that sometime may contain sensitive content by hiding some part of it.

    Although this plugin works fine, I would like to have the script enhanced to also display an short warning message within this specific post to advise users they most be logged to read the complete post. Again, this short warning must be specific to this post having these tags only.

    Actually, that is the script:

    *//

    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; }
    }

    *//
    So basically, when a user is not logged, it should not only hide the text inside the <!–hidethis–> tags but also display warning message to users that the complete post is available ONLY if logged.

    Anyone have an idea how to?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jessenco

    (@jessenco)

    OK HERE IT IS!
    WORKING GREAT IN WORDPRESS 2.0.2
    NOT TEST IN OTHER VERSION.

    Save in your plugin folder the following code in a file named “HIDETHIS.PHP“.
    Activate as usual in the Admin panel.
    That’s it !
    Usage : <!–hidethis–> <!–/hidethis–>

    Whenever you want to censure just a part of text anywhere in a post to people not logged (or registered) on your blog
    just put the sensitive section of text wiithin these tags <!–hidethis–> <!–/hidethis–>.

    This will replace all the text within these tags by a nice warning message to people saying the this portion of text is censured, they need to login to see the uncensured post.

    AGAIN, THIS WILL ONLY HIDE THE TEXT WITHIN THE TAGS not all the post.

    EXAMPLE : Bla bla bla <!–hidethis–> hide this text because it is too hot <!–/hidethis–> bla bla bla.

    When used like above example, people not logged will see:
    Bla bla bla …contend censured. Please login!… bla bla bla.
    People logged will see: Bla bla bla hide this text because it is too hot bla bla bla.

    Cool isn’t it ?

    You can customize the HTML warning message to display as you want;

    – maybe to display an image intead of a textual message.
    – adding a link to your login page
    – etc.

    It is a modification of the HIDETHIS plugin made by Mark Edwards found in WordPress codex.
    Modify by myself and GaMerZ to suit my need.

    Please give credit to Mark Edwards.

    Here is the script:

    <?php
    /*
    Plugin Name: HideThis
    Plugin URI: https://www.edwards.org/tags/Wordpress
    Description: Hides parts of posts from readers who are not logged in. Begin hidden content with <!--hidethis--> and end hidden content with <!--/hidethis-->
    Version: 1.0.1
    Author: Mark Edwards
    Author URI: https://www.edwards.org

    Copyright ? 2006 - Mark Edwards

    Drop it in your plugins dir and activate. Then wrap the text to be hidden with <!--hidethis--> and <!--/hidethis-->

    Example of post with hidden content:

    This is a test post I wrote to see if this plugin works.
    <!--hidethis-->
    this text will be hidden if a reader isn't logged in
    <!--/hidethis-->
    And so this is the end of the post.

    */

    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)){
    $hide_msg = "<table width="243" border="0" cellpadding="0" cellspacing="0">
    <tr><td width="306" align="center" valign="middle" nowrap bgcolor="#FF0000"><strong> ...content censured! Please login...</strong></td></tr></table>";
    $b = strpos($content, '<!--hidethis-->');
    $e = strpos($content, '<!--/hidethis-->');
    $pre = substr($content,0,$b);
    $suf .= substr($content,$e,strlen($content));
    if($b === false) {
    return $pre.$suf;
    }
    return $pre.$hide_msg.$suf;
    } else {
    return $content;
    }
    }
    ?>

    not work ??

    where can i ger the plugin to please ?? the Mark Edwards site isnt working, please someone help me now???????

    The code is in the post above. Copy everything from:

    <?php
    /*

    to

    }
    ?>

    and paste into your favourite plain text editor (Notepad will be fine). Make sure you don’t leave any spaces in your new file before or after the text you copied.

    Save the file as hidethis.php and upload to your plugins folder and activate in the normal way.

    And if you’re being picky, you might want to change “content censured” to “content censored”…

    I can’t guarantee that the plugin will work for you, but that’s how to get it…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hiding sensitive content to youngster from public reading.’ is closed to new replies.