'Restricted Content', 'pi_version' => '1.0', 'pi_author' => 'Brian Litzinger', 'pi_author_url' => 'http://www.brianlitzinger.com/ee/', 'pi_description' => 'Show blocks of content only to allowed member groups.', 'pi_usage' => Restricted::usage() ); class Restricted { var $return_data; function Restricted() { global $TMPL, $SESS; $tagdata = $TMPL->tagdata; $group_id = $TMPL->fetch_param('group_id'); $matches = array(); if(!$group_id or !$tagdata) return; foreach ($TMPL->var_pair as $key => $val) { if (ereg("^no_access", $key)) { $temp = preg_match_all("/".LD."no_access".RD."(.*?)".LD.SLASH.'no_access'.RD."/s", $TMPL->tagdata, $matches); } } if(count($matches) == 0) { $this->return_data = 'Please define alternate {no_access}{/no_access} content.'; return $this->return_data; } else { foreach($matches as $k => $v) { if($k == 1) { $no_access_content = $v[0]; } } $group = explode('|', $group_id); //$group[] = 1; // Add super admin's to the allowed list. if( ! in_array($SESS->userdata['group_id'], $group) ) { $this->return_data = $no_access_content; $this->return_data = trim(str_replace('
', '', $this->return_data)); } else { // Remove the {no_access} tag pair $this->return_data = preg_replace("/".LD."no_access".RD."(.*?)".LD.SLASH.'no_access'.RD."/s", '', $TMPL->tagdata); } return $this->return_data; } } // END // ---------------------------------------- // Plugin Usage // ---------------------------------------- // This function describes how the plugin is used. // Make sure and use output buffering function usage() { ob_start(); ?> Wrap content you want to allow to specific member groups with the plugin. If a person is not of one of the defined member groups, then they will see the content you define between the {no_access} tag pair. {exp:restricted group_id="5|6|7"} {no_access} Please log in to download the secret list. {/no_access}

Download SecretList.pdf

{/exp:restricted} To use this with a custom field wrap the field with the allow_eecode plugin: http://expressionengine.com/downloads/details/allow_ee_code/ {exp:allow_eecode} {body} {/exp:allow_eecode} The {body} field can contain exactly what is seen in the first example. Parameters ------------------ group_id= (required) Pipe separated list of allowed member group IDs. Super Admins are included by default. text_format= (optional) 'xhtml', 'br', 'none', 'lite'. Default is 'xhtml'