Membership API

Discussion in 'Troubleshooting' started by alexzain, Feb 22, 2016.

  1. alexzain

    alexzain New Member

    Joined:
    Feb 20, 2016
    Messages:
    3
    I have a working api for login but not for membership login. Any anyone with or without
    a valid membership can login. How can i make it to work with anyone with a membership
    product can login.

    If anyone with a valid membership then echo "OK Success Logged In"

    If subscription expired then echo "Subscription Expired"

    If username or password mistyped then echo "Invalid Username or Password"

    I WANT IT TO WORK WITH ANY PRODUCT MEMBERSHIP.

    ------------------

    <?php

    require_once 'amember/bootstrap.php';
    require_once 'amember/library/Am/Lite.php';

    $login = $_POST['username'];
    $pass = $_POST['password'];

    $code = null;

    $user = Am_Di::getInstance()->userTable->getAuthenticatedRow($login, $pass, $code);
    $result = Am_Di::getInstance()->auth->login($login, $pass, $code);
    if (!$user) {
    echo "ERROR No Valid Membership Assigned";

    } else {


    $u = Am_Di::getInstance()->auth->getUser();
    Am_Lite::getInstance()->isLoggedIn();

    echo "OK Success Logged In";


    // user is an instance of User class : application/default/models/User.php
    }


    ?>
  2. alexzain

    alexzain New Member

    Joined:
    Feb 20, 2016
    Messages:
    3
    Any support anyone
  3. alexzain

    alexzain New Member

    Joined:
    Feb 20, 2016
    Messages:
    3
    How can i say if any membership product then echo "Success Logged In"
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,682
    Please have a look
    http://www.amember.com/docs/API/Lite

    Code:
    Am_Lite::getInstance()->isLoggedIn();
    Am_Lite::getInstance()->haveSubscriptions($search);
    Am_Lite::getInstance()->checkAccess($require, $title = '');

Share This Page