Embed Login

Discussion in 'Templates customization' started by cmashburn, Feb 28, 2014.

  1. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    I am currently using a script where I could simply insert one line of code to any page and I would get the login box (http://www.southwest.org/membersection/index.php).

    Is this possible with aMember? Salesperson told me it was.

    Is the only way to do this by setting up a custom theme? We also have a separate mobile site which would need a different theme. If themes are the only way to do this, is it possible to use two different themes at the same time depending on which site (full or mobile)?
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    The login box comes down to a form. User enters their username and password into respective fields and then hit submit to submit the form.

    There is no reason why you cannot design your own form and embed it into your page - more than once if you want to.

    You just need to keep to aMember variable names and use the same action as the aMember one.
  3. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Okay, so a simple form will do the login. I will try that out. However, is there some way to ackowledge if someone is already logged in? My example above will show a box with the text link "You are already logged in, proceed to member section".
  4. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    Without getting involved with aMember core files, which might change when upgraded, why not do a simple check using the aMember Am_Lite function to check if a person is already logged in before submitting your form.

    A simple 'IF' statement such as if logged in show box else submit form would work I would have thought.
  5. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Forgive my ignorance. While I have been successful in the past customizing PHP scripts, I am by no means very capable in all this.

    I have this page which talks about the Am_Lite (http://www.amember.com/docs/API/Lite).

    However, there are not details on how to actually put this code in a PHP file.

    I tried this...

    But I get nothing on the page (the location of the directory is correct). Nothing is rendered.
  6. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Okay, I seem to have got it working by changing the code a little to...

  7. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Would you be able to help me write a If/Else PHP code? If they are logged in already (Am_Lite::getInstance()->isLoggedIn()), I would like it to provide a link to the Member Section.

    If they are not logged in I would like to render the login form (Am_Lite::getInstance()->renderLoginForm() )
  8. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Well, looks like I was able to successfully write it...


    My latest question is on formatting the "Am_Lite::getInstance()->renderLoginForm()"

    Right now, echoing this just puts all the text and boxes on one line with no space between them. Is there anyway to edit how that form renders?
  9. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    I will try to come up with something but it probably will not be until the weekend.

    In the meantime in order to make the form render formatted you will probably have to include a link in your page to the aMember CSS file or copy the relevant parts into your own file.
  10. cmashburn

    cmashburn aMember Pro Customer

    Joined:
    Feb 25, 2014
    Messages:
    7
    Thanks so much. I did, however, stumble on a solution. I took a look at the lite.php file that is reference in the am_lite code. There is code in that file for how the form renders. So I think I can simply add to css references to it (using my website css) and get it to render how I want.

    And, I suppose, I can make a separate lite.php (copied to lite2.php) for my mobile site using different formatting.

    My initial testing has worked just like I hoped.

Share This Page