A few notes about the project:
This is for an online version of a company's handbook / operating guidelines. This is being built on Wordpress (so you may see some functions specific to that).
Code: Select all
<?php
/* Custom function for hiding parts of the post */
function hide_this($text, $userlevel = '2' )
{
global $userdata;
get_currentuserinfo();
if ($userdata->user_level < $userlevel)
{
$text = '';
}
else
{
echo $text;
}
}
/* End function */
$currentPage = get_page($page_id);
$fullContent = $currentPage->post_content;
preg_replace(
"#(::[ ]*hide[ ]*::(.+)::[ ]*/hide[ ]*::)#imseU",
" /* THIS IS WHERE I AM CONFUSED */ ",
$fullContent
);
?>So, the idea here is that anywhere that I have the following setup:
Code: Select all
::hide::
This should be hidden from normal viewers.
::/hide::
This should be visible to normal viewers.My checks on the user and whatnot (the Wordpress-centric parts of this) work fine, but I'm not sure what I should be replacing everything with (see the THIS IS WHERE I AM CONFUSED section of the code). Honestly, I'm not sure that this is the best way to go about it.
I think that I need something like:
Code: Select all
preg_replace(
"#(::[ ]*hide[ ]*::(.+)::[ ]*/hide[ ]*::)#imseU",
"hide_this(THE STUFF BETWEEN THE TWO TAGS)",
$fullContent
);