TinyPortal

Development => Support => Topic started by: pvcblue on November 29, 2006, 12:45:52 PM

Title: Articles
Post by: pvcblue on November 29, 2006, 12:45:52 PM
Is there a way to make it so ONLY members can read articles, maybe even just members of a certain level?  :o
Title: Re: Articles
Post by: IchBin on November 29, 2006, 01:34:30 PM
http://www.tinyportal.net/smf/index.php?page=14
Title: Re: Articles
Post by: Thurnok on November 29, 2006, 11:00:25 PM
In the mean time, you can right now but it is a bit more difficult than simply entering the data for a new article.

First, you need to make a PHP article.

Next, in the article body you would surround the information that members are allowed to view like so:

// set up global variables
global $context;

// if user is a member (they are logged in) then show them article
// alternative: (!$context['user']['is_guest'])
if ($context['user']['is_logged']){
// use echo statements to display information here
// example
echo 'This is my article text.  Please read it thouroughly or you will be smited!<br />';
echo 'This is more information, don't forget to read it!';
} else {
echo ' <p /><center>Sorry, you do not have access to this information.</center><br />';
}


If you wanted to limit the viewing to certain membergroups, you could do something like this:

// set up global variables
global $context, $user_info;

// if user is a member of membergroup 7, or 9, then show them article
$valid_groups = array(7,9);
if (array_intersect($valid_groups, $user_info['groups'])){
// use echo statements to display information here
// example
echo 'This is my article text.  Please read it thouroughly or you will be smited!<br />';
echo 'This is more information, don't forget to read it!';
} else {
echo ' <p /><center>Sorry, you do not have access to this information.</center><br />';
}

Title: Re: Articles
Post by: pvcblue on November 29, 2006, 11:00:58 PM
oh, not until version 1.0,  :'(
Title: Re: Articles
Post by: rebelrose on November 29, 2006, 11:39:59 PM
That is very nice information Thurnok.