Customizing phpbb form area with am lite

Discussion in 'Integration' started by dale_sellers, Oct 19, 2014.

  1. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I have a custom login form on my phpBB forums I am creating. I don't want to automatically subscribe all new aMember users to the forums when signing up as a member on my site for other things, but I would like them to have the options to subscribe to the forums whenever they like.

    I have the form itself figured out. The issue is how to display different messages (where the form is located in phpBB) to the user depending on if they are logged in, logged out, a member of site but not a subscriber to the phpBB forum, etc. You can see the current version of the login form here:
    http://www.lifeleap.org/communn/index.php

    I have seen several places in the aMember forums where AM Lite can be easily used to show different returns for logged-in and not-logged in users. Such as this:

    Code:
    require_once '/home/myusername/public_html/amember/library/Am/Lite.php';
    if (Am_Lite::getInstance()->isLoggedIn() )
    {
      echo "Logged-in" . Am_Lite::getInstance()->getName();
    } else {
      echo "Not Logged-in";
    }
    But I need the form area I have to create the following scenario:

    1. logged out - shows my custom aMember form
    2. logged in but not with a subscription to phpBB - shows text with link back to member area so user can subscribe to forums
    3. logged in with a subscription to phpBB - shows different set of links such as manage forum posts, manage forum private messages, etc.

    This will prevent confusion for members who are logged in but who haven't subscribed yet, along will showing the user only the part of the form area that applies to them. This would be good to have, not only for phpBB, but also for people using other integrated scripts - Magento, etc.

    I know the wordpress widget will do this sort of thing, but not sure about how to do it with straight code.

    My guess is that the code would need 2 if statements and the following 2 classes:

    Am_Lite::getInstance()->isLoggedIn()
    Am_Lite::getInstance()->haveSubscriptions($search)

    I've got all the html (for forms, links, etc) worked out, but I could use some help with the if statements. I'm not sure quite how to combine the instances of AM Lite together. Thank you for any suggestions.
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    Try:
    PHP:
    if (Am_Lite::getInstance()->isLoggedIn()) AND (Am_Lite::getInstance()->haveSubscriptions($search) )
    /* do these instructions */ }
    else
    /*do these  */ }


  3. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    the hpmc - thank you for the reply. You suggestion seems like it will work for being logged in with a subscription, but what about logged in without a subscription (to phpBB, etc)? I've been going through the forums and knowledge base and haven't been able to find anything about this yet. Is there a syntax that can be used with AM Lite, to create a return when something specifically does not exist?

    My guess is that the complete code has to include the following returns:

    1. logged out
    2. logged in, but not with an aMember subscription to phpBB
    3. logged in, with an aMember subscription to phpB

    This will allow the form area to display three different scenarios when a user visits the phpBB forums of site:

    1. an aMember custom login form (when user is logged out)
    2. a link back to member's area with a suggestion to create a subscription to phpBB (when user has an aMember membership to something else on website but not an aMember subscription to phpBB)
    3. forum user-related content and links (when user has an aMember membership, and one of the aMember subscriptions is an aMember phpBB subscription)

    Although, maybe I'm missing something and there is another way of doing it. Thanks for any suggestions.
  4. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    Also, when user is not logged in at all, above login form, I planned on putting a link "signup or login for access if not subscriber to forum."

    I think this would make the whole setup complete.
  5. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    This is critical for a site like ours. We have over 7000 subscribers, for various products. We don't want them all to have subscriptions to the forums initially. If this was so, all members would get messages from the forums, including from other forum members, without their consent.

    So there would be several thousand members subscribed to the forums who never are active in the forums, and most who never visit the forums. Would be great to find a solution for this. Thank you for any suggestions.
  6. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    To answer need some idea how your members get to be subscribed to phpBB.

    For example they register with aMember, presumably with no automatic access to phpBB, but what happens next?
  7. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I have it set up as an Amember subscription available as a free product subscription. If they sign up to the phpBB forum subscription in aMember, they can then login and use forums.
  8. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    So if phpBB access is determined by which aMember product they signed up for then all you need do in order to determine form to display is basically same as I suggested above.

    1. logged out - shows my custom aMember form
    Check if they are logged in or not. using am/lite.php and display your custom form if not.


    2. logged in, but not with an aMember subscription to phpBB
    3. logged in, with an aMember subscription to phpB

    Use am/lite.php call to check what products they are subscribed to and if they are subscribed to the one including the forum display.

    Then, depending upon product, display correct form for phpBB subscribed or not subscribed as appropriate.
  9. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    Thank you thehpme. That's make perfect sense. I will test it out.

Share This Page