Hi.

Congratulations to develop this module.

I've getting an error to make hide text just for anonymous users. I installed drupal recently, which I still have not defined roles in addition to default ones. But when I put some text between the code, this text is hidden to everyone, including the administrator.
I tried to put [restrict:roles=anonymous user], but the result was always the same.
The input is well defined, the module is properly installed, but I do not know where I can configure this module.

Sorry my bad English...

Comments

antistructure’s picture

I am having the same problem, changed the order of the filter, and tried the [restrict:roles="authenticated users"] but no go. Also got an error in my status updates page:

warning: Invalid argument supplied for foreach() in /usr/local/www/drupal6/sites/all/modules/restricted_text/restricted_text.module on line 167.

antistructure’s picture

Ok, so I whipped up a temporary hack that can be stuck into your theme page.tpl.php file (I know, its just a hack) using some of the code from the module.

 <?php
 
function restricted_text_hack($user, $text)
{
  
   if (in_array("anonymous user", $user->roles))
   {
    
    // (Taken directly from the restricted_text module)
    // This lovely piece of regular expression finds all of the [restrict][/restrict]
    // blocks and passes them to the callback. (note: no callback)
    $text = preg_replace('/\[restrict\](.+?)\[\/restrict\]/sm', "", $text);
    return $text;
    
   }
   else
   {

     $text = preg_replace(array('/\[restrict\]/', '/\[\/restrict\]/'), "", $text);
     return $text;

   }
}

$content = restricted_text_hack($user, $content);

?>

This of course will only handle the [restrict] ... [/restrict] blocking content from anonymous users only.

pukku’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)