Am_Lite Avatar

Discussion in 'Setting-up protection' started by edward_shephard, Jan 12, 2017.

  1. edward_shephard

    edward_shephard aMember Pro Customer

    Joined:
    Aug 22, 2014
    Messages:
    41
    If you're using Am_Lite to control access to your own PHP scripts is there any way to show the users avatar in a:

    PHP:
    <img src='".Am_Lite::getInstance()->avatar."' height='40px' width='40px'/>
    sort of way?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,642
    Yes, it is possible to do:
    PHP:
    <?php if ($u Am_Lite::getInstanse()->getUser()) : ?>
    <img src="<?= Am_Lite::getInstanse()->getRootUrl() ?>/avatar/<?= $u['avatar'?>" />
    <?php endif; ?>
  3. edward_shephard

    edward_shephard aMember Pro Customer

    Joined:
    Aug 22, 2014
    Messages:
    41
    Thanks. However $u['avatar'] seems to be returning the upload_id from am_upload. How can I get from there to the actual filename and the correct path within /data/ please?
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,642
    Yes, it is upload_id but if you try to open url
    http://example.com/amember/misc/avatar/upload_id
    You will see avatar image.

    I see I made mistake (miss 'misc' part in url) in my previous post.
    The code should be:
    PHP:
    <?php if ($u Am_Lite::getInstanse()->getUser()) : ?>
    <img src="<?= Am_Lite::getInstanse()->getRootUrl() ?>/misc/avatar/<?= $u['avatar'?>" />
    <?php endif; ?>
  5. edward_shephard

    edward_shephard aMember Pro Customer

    Joined:
    Aug 22, 2014
    Messages:
    41
    Hi that worked great thanks, although just in case anyone else needs it getInstanse should be getInstance. I can now replicate the user block on my protected php pages. :)

    Screen Shot 2017-01-16 at 16.26.22.png
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,642
    Ohh, shame on my head. Yes, it should be getInstance

    By the way user block looks cool.
    edward_shephard likes this.

Share This Page