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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 366
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 274
  • Total: 275
  • @rjen

How To Restrict Guest From Viewing Articles

Started by tribalost, May 08, 2007, 12:47:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchBin

No you can't. Which is why theirs an approval system though.

JOSHSKORN

Quote from: IchBinâ„¢ on May 25, 2007, 03:19:26 AM
You're questions seem a bit vague. But if you don't want to show an article to anyone unless they're a member of your clan group then you can change this code to do it.
Change the number 3 to the number the corresponds to your group number in your forum.

global $user_info;
if ($user_info['groups'] == 3){
echo 'your code goes here';
}

Doing this type of thing will not print any of your article to the page.

OK I hope I'm clear enough as to what I want with this request...

echo 'your code goes here';

This line of code means absolutely nothing to me. I'm not a PHP expert, therefore cannot interpret what you're saying, here.

In your IF block of your suggested code, how to I pull this page (http://www.mysite.com/smf/index.php?page=16) if my test is true (that is, if the member is allowed to view the article)?  The article is created with the regular editor, not PHP.  Do I need to create the actual article IN PHP instead, thus not having an article # to link to?  Do I need to create a regular article, click the source button, copy the code and paste it into my php article inside the if block?

Once again, my concerns:
  • Security - Don't want someone to right-click, get the source of the article, which may be article #16 (like in my example above) and be able to directly link to it, overriding security.
  • I don't want my code to test for a specific group number.  I want it to test to see if the person accessing the article, their primary membergroup begins with a specific string (once again, CM, so I'd have CM~Admin, CM~Captain, etc.).  I don't want to go through the hassle of finding the group numbers of each.
Hope this is clear enough.

Zetan

#12
Most .php cannot be viewed from the source as it's pulling information from the server.
Which means that anyone viewing the source will see the php code.. but not the information displayed that is being pulled from the server.

Not all articles need to be php.. you can use regular html too.

echo 'your code goes here';

The rest of you're article code, script is inserted between the '  ' that IchBin posted.

The IF user is... cannot be linked to and viewed.. If User is guest... they will see a warning message.

Xeriar

Quote from: IchBinâ„¢ on May 26, 2007, 04:30:55 AM
No you can't. Which is why theirs an approval system though.

Ugh.  Hmm.

Is it possible to have a setup where users could make and edit their own little blog-sections, but not those of others?

IchBin

There's no user specific permission built into TP yet for articles.

Polymath

#15

if (!$context['user']['is_guest']){
echo '
<h5>Access Denied</h5>
  We are sorry. You must be registred with us in order to view giveaways.';
} else  {
echo '
<style type="text/css">
#ga_block { width: 250px; background-color: #F2F2F2; padding: 6px; border: 1px solid Blah blah blah balah blah blah blah blah

';
}


ok. this don't work. I want it so say " Access Denied
  We are sorry. You must be registred with us in order to view giveaways. " when not registered and logged in. But all it does is say that all the time evem to me(admin)

Have I missed some thing? Please.

This works:

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}


But there is no message at all, not even an error. I would like it to encourage registration.

Thanks

IchBin

Using the ! at the beginning is like saying, if the user is "not" a guest. Take the ! out, and it will check to see if the user "is" a guest. :)

Polymath

Thank you very much. That sorts out viewing articles the quick way.

MPDesignZ

Quote from: IchBinâ,,¢ on May 24, 2007, 12:17:45 AM
if you want a work around you can use some php code to do it.

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}


This will only display the article if the user is not a guest.

Awesome! Thanks this worked for me. :D

This website is proudly hosted on Crocweb Cloud Website Hosting.