TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 11:37:24 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 86
  • Total: 86

Anyway to password protect articles?

Started by dry3210, December 18, 2007, 04:22:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dry3210


IchBin

You could add your own custom PHP code to articles. If you google search it I bet you can find something.

lebisol

Consider htaccess
http://www.htmlgoodies.com/tutorials/getting_started/article.php/3479531
or as Ich said enter a small php code (you would have convert all articles to php) to check "if user member group =x Then echo ....article ...Else "sorry"

TimUSA


lebisol

unlike forum baords articles are public...ACls only apply to edit/add/submit no 'view'.
I think he is looking for just a password protection to articles for guests and memebers...suppose the author will say more...
All the best!

TimUSA

#5
true, what i was suggesting is something like:
global $user_info;

if (count(array_intersect(array(1,9,10,11,12,13), $user_info['groups'])))
{
echo '***Your HTML here***';
}


This will show your article only to the selected member groups. So instead of a password, you would change their member group.

dry3210

Quote from: TimUSA on December 18, 2007, 07:56:12 PM
true, what i was suggesting is something like:
global $user_info;

if (count(array_intersect(array(1,9,10,11,12,13), $user_info['groups'])))
{
echo '***Your HTML here***';
}


This will show your article only to the selected member groups. So instead of a password, you would change their member group.

That should work then! 

Yeah basically I wanted it so some articles are viewable by all..and others are restricted some how membergroup or password

evilicy

#7
I know this was already resolved but wanted to share this code anyways and figure might as well post it here since it is related.

Remember the old Javascript "the gate keeper"? that pw protected pages I used to get a kick out of it. Well here it is again with the same fun novelty but in php for php articles.

DEMO
Password is: password


// Define your password

$password = "password";



if ($_POST['txtPassword'] != $password) {

echo '<img src="http://darkvoid.org/images/keeper.gif">

<form name="form" method="post" action="'; $_SERVER['PHP_SELF']; echo '">

<p><label for="txtpassword">Password:</label>

    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>

<p><input type="submit" name="Submit" value="Enter Password" /></p>

</form>';

}

else {

echo "<p>This is the protected page. Your private content goes here.</p>";

}


PS

I didn't write the original gate keeper script or the php code provided. I simply googled the code and added the novelty of the Gate keeper to it :P

Innocenzia

Is there a way to make the information in an article viewable only for nonmembers, let say i want it to say: "please join.  blaha, blaha.." then i wouldn't want the members to see it, in stead i want the members to see: "Hi Member. blaha, blaha.." so the same article, but different text for members and nonmembers?

IchBin

if ($context['user']['is_guest'])
    echo 'The code here for a guest that you want';

if ($context['user']['is_logged'])
    echo 'The code here for logged in users';