Protect link from access

Discussion in 'Setting-up protection' started by bdmc, Mar 30, 2012.

  1. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Hello,

    How I can protect a link from accessing it? I went to Configuration / Links, added a new record and added the website URL. I just noticed that it does not work.

    By exemple, if a non-member wants to click on a special link, it should redirect him to a login page and once logged on, it will redirect him back to this link.

    How I can do that?

    Thanks
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This is impossible to protect links such way.
    aMember CP -> Protect Content -> Links can be used only to display additional links available for users. It does not protect links.
  3. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Then what's the use of Products / Protect Content in the Admin panel? Even if I protect the whole Page, still it does not protect it in any way.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    My note above was only about links.
    If you protect page/folder/video etc... from aMember CP -> Protect Content , content will be protected.
    But there is clearly no way to protect links. This is just impossible.
  5. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    You have to add this feature in your next version...if there`s one..
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    So you want to display a link, but when the user clicks on the link, if they arent logged in then they get redirected to another page? Are you using wordpress?
    If the link is a wordpress protected page- you can set the redirect for non-members.

    David
  7. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    >>So you want to display a link, but when the user clicks on the link, if they arent logged in then they get redirected to another page? YES

    Sadly, I don't use WordPress.

    I just found out that the specified page cannot be protected fom PRODUCTS / PROTECT CONTENT / LINK. If the user logs-in and is directed to the specified page, it's fine. But if another user does not want to log-in and have an idea what the link does look like, he still can access this page without having to be logged in. I am turning around with no idea how I can protect this page :(
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You have to protect that page itself and not link. If this page is on your server, aMember offer several ways to set protection in aMember CP -> protect Content. If this page is on different server, unfurtunately nothing can be done to protect it. And this is even impossible to protect link. The problem is not in aMember, such protection just will not work.
    If you can open link in your browser you can share this link with others.
  9. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    This page is on the server. I went thtough aMember CP --> Protect Content --> Protect pages, but there is nothing that actually makes the page protected. If there is a field where I can paste the link to this page, then it can be protected...
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  11. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    This page had a .html extension and was converted to a .php extension.

    I added this script at its very top.

    Code:
    <?php
    session_start();
    
    if(!isset($_SESSION['login']))
        {
        header("Location: http://signipedia.com/amember/login?amember_redirect_url=http://signipedia.com/fable4.php");
        exit;
        }
    ?>
    From the link you gave me, if you suggest that I have to use Am Lite to protect this page
    Code:
    <?php
    include("aMember_Root_Dir/library/Am/Lite.php");
    Am_Lite::getInstance()->checkAccess(array(ONLY_LOGIN), 'Fables');
    
    session_start();
    
    if(!isset($_SESSION['login']))
        {
        header("Location: http://signipedia.com/amember/login?amember_redirect_url=http://signipedia.com/fable4.php");
        exit;
        }
    ?>
    The user does not have any paid membership, so checkAccess was changed to ONLY_LOGIN

    But still can't get it to work.
  12. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Just use this code in order to protect page and handle redirects:
    PHP:
    <?php
    include("aMember_Root_Dir/library/Am/Lite.php");
    Am_Lite::getInstance()->checkAccess(array(ONLY_LOGIN), 'Fables');
    ?>
    // Your other content here
    this:
    PHP:
    session_start();

    if(!isset(
    $_SESSION['login']))
        {
        
    header("Location: http://signipedia.com/amember/login?amember_redirect_url=http://signipedia.com/fable4.php");
        exit;
        }
    Just will not work with aMember 4
  13. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Thanks a lot for your help. It works now. :)

Share This Page