Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Only Registered User can access

Asked Modified Viewed 5,526 times
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
asked
Junior Member

Sorry if this was asked before but may I know how I can restrict my website so that only registered users can view the website? example: Guest would only see a login page when they try to access the site. They must either login or register to gain access to the website. Thank you.
Edited by mode12 on 02-06-2011 11:49,
0 replies

18 posts

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Hi there,

OK...

In a panel put...

if (!MEMBER) { redirect(BASEDIR."login.php"); }


Enable it as lower center or upper center and display on all pages.

Now guests will be redirected to login.php
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

Sorry but I can't seem to get it to work. I went to Admin Panel > System Admin > Panels > Upper Center[New Panel] > Panel name (eg. Test) > Panel Filename (None) > Panel Content (I delete everything and paste the code you gave me :
if (!MEMBER) { redirect(BASEDIR."login.php"); }
> Panel Side (Upper Center) > Display in all pages > Public > Enable

However, when i log off and access the website as guest nothing has changed. I still can access the website and see its contents.
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Is the panel set to public?
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

yeah

Merged on Jun 02 2011 at 13:58:25:
any ideas why?
Edited by mode12 on 02-06-2011 14:58,
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

What's your site link?
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

What do you mean?
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

What is the link to your site? So I can see.
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

fixed it but accidentally put if
(!iMEMBER) { redirect("index.php"); }
instead of login.php and now I cannot access my website as it keep redirecting. Any ideas?
Edited by mode12 on 02-06-2011 16:15,
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

What's your site link? I might be able to fix it for you.
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

hold on may I pm you as it is actually suppose to be made private so....
Edited by mode12 on 02-06-2011 16:19,
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Not much I can do there as it's password protected.

Quote

A user name and password are being requested by http://www.alphaextreme.com. The site says: "Please type in the access username and password given. Note: This is not your account. You still have to register later (for those who haven't done so…"


Sure PM Me.
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

Just curious what is the difference between !imember and !member in the code?
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

iMEMBER = if a member
!iMEMBER = If Not a Member

! always means NOT
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

For some reason when I try this code:

if (!iMEMBER) { redirect(BASEDIR."login.php"); }


and try to access my website it shows this error:
the server is redirecting the request for this address in a way that will never complete.
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

Man ! If you will have that panel enabled on that login.php page too then it will again redirect you to the page and then again and this will result in a Redirect Loop...

So, you can remove this panel from login.php to work by Editing the panel...

Go and Edit this panel you've made. There you will find Panel Restriction: with Exclude on these pages and Include on these pages Button...

In that box, write /login.php and set it to Exclude on these pages and see if it works... :)
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Also

if (!iMEMBER && FUSION_SELF!='login.php') { redirect(BASEDIR."login.php"); 
}


Quote

if ( I'm NOT a member AND this_page NOT a login.php )
0 replies
M
mode12
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions
answered
Junior Member

Thank you both very much for your help. I will try it out :)

Merged on Jun 03 2011 at 07:44:53:
It worked. Thank you very much. I was wondering is it possible to make it look just like when the website is under maintenance :) I find it much nicer :) Thank you.
Edited by mode12 on 03-06-2011 08:44,
0 replies
L
lelebart
L
I don't know! I don't know why I did it, I don't know why I enjoyed it, and I don't know why I'll do it again! Bart Simpson
  • Member, joined since
  • Contributed 133 posts on the community forums.
  • Started 21 threads in the forums
answered
Member

Some times ago an Italian user made a similar request: check there if it can help you http://php-fusion.it/forum/viewthread...post_16648

He needs to restrict access for few sections: download items and thread forum ones, here's the code, set it as a upper-central panel:
if (iGUEST) {
   // forum thread
   if (isset($_GET['thread_id']) && !empty($_GET['thread_id']) && isnum($_GET['thread_id'])) {
      redirect(BASEDIR.'login.php?from=forum');
   }
   // single download
   if (isset($_GET['download_id']) && !empty($_GET['download_id']) && isnum($_GET['download_id'])) {
      redirect(BASEDIR.'login.php?from=download');
   }
   // explicative messagge
   if (isset($_GET['from']) && !empty($_GET['from'])) {
      $from = stripinput($_GET['from']);
      switch ($from) {
         case "forum":
            $title   = "Redirecting from discussion forum";
            $message = "In order to read this forum thread you must be a registered user.";
            break;
         case "download":
            $title   = "Redirecting from download section";
            $message = "In order to see this download you must be a registered user.";
            break;
         default:
            $title   = "Redirecting from a restricted section";
            $message = "In order to see this resource (".$from.") you must be a registered user.";
      }
      opentable($title);
        echo "<p>".$message."</p>";
        echo "<p>".($settings['enable_registration'] ?
         "<a href='".BASEDIR."register.php'>Create an account</a> on this site, or use " :
         "Use ")."your username and password to login.</p>";
      closetable();
      unset($from, $title, $message);
   }
}


demo: http://www.valeriovendrame.it/701/log...ource%20is
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 18 posts
  • Votes 0 votes
  • Topic users 5 members

5 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
L
L
I don't know! I don't know why I did it, I don't know why I enjoyed it, and I don't know why I'll do it again! Bart Simpson
  • Member, joined since
  • Contributed 133 posts on the community forums.
  • Started 21 threads in the forums
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
A
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
M
M
mode12 10
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 2 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet