Show users only the products they have access to

Discussion in 'Customization & add-ons' started by pepacobos, May 3, 2017.

  1. pepacobos

    pepacobos aMember Pro Customer

    Joined:
    May 7, 2012
    Messages:
    27
    Hi, I sell online courses through aMember.
    If someone purchases a course then he sees the course (or courses) purchased in their user dashboard but I'm looking to create a home page where, once the user is logged-in, he can see all the courses he has access to, so he can then click in any of them and enter.
    I want to make it "pretty" so each course has its own icon but that is fine for me (I know how to deal with those tweaks) I just only want to know if it's possible to achieve that (showing the enrolled courses in any page) using aMember.

    Any help would be greatly appreciated. Thanks!
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
  3. pepacobos

    pepacobos aMember Pro Customer

    Joined:
    May 7, 2012
    Messages:
    27
    Thanks!! So, if I have understood I need to create a PHP file with that function and it will return the links to all user's active subscriptions?

    Thanks again!
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Yes, you are right.
  5. pepacobos

    pepacobos aMember Pro Customer

    Joined:
    May 7, 2012
    Messages:
    27
    Thanks again. I have created a PHP page and have included the Lite.php library. Till here everything is working fine.
    Then I have added $links = Am_Lite::getInstance()->getUserLinks(); but I think I need to create some type of function so it collects the links and then show them in the page.

    I am no expert in PHP and am a little bit lost. Can you point me in the right direction?

    Thanks!
  6. pepacobos

    pepacobos aMember Pro Customer

    Joined:
    May 7, 2012
    Messages:
    27
    I have come with this code but it is returning NULL:
    PHP:
    <?php
    require_once '/home/user/public_html/alumnos/amember/library/Am/Lite.php';

    $links Am_Lite::getInstance()->getUserLinks();

    if(
    $links)
    {
        echo 
    '<ul>';

        foreach(
    $links as $link)
        {
            echo 
    '<li>' $link '</li>';
        }

        echo 
    '</ul>';
    }

    // always good to see exactly what you are working with
    var_dump($links);
    At this point I'm completely lost...

    I have tried to log in as another user and then I get array(0) { }
    Last edited: May 5, 2017
  7. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295

Share This Page