• At some point in time following an initial post I want to be able to edit it in such a way that the edited portion will be hidden from unauthorized readers. What’s the easiest way to accomplish this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Shortcodes maybe.

    Here is a short bit of code to add to the end of your functions.php. It provides the [mm-hide-text] shortcode. All text between [mm-hide-text] and [/mm-hide-text] will be hidden from all but Admins.

    <?php // [mm-hide-text]some text here[/mm-hide-text]
    function mm_hide_text_func($atts, $content=null) {
       extract(shortcode_atts(array('noatts' => 'Unknown' ), $atts));
       $output = '';
       if (!is_null($content) && current_user_can('administrator')) {
          $output = $content;
       }
    
       return $output;
    }
    add_shortcode('mm-hide-text', 'mm_hide_text_func');
    ?>
    Thread Starter vyrlson

    (@vyrlson)

    Thanks a lot for this. I’ll try it out.

    You are welcome. If it works for you, please use the dropdown at top right to mark this topic ‘Resolved’.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hiding text in a post’ is closed to new replies.