Using username in a link

Discussion in 'Troubleshooting' started by sahebxalsa3ada, Dec 28, 2014.

  1. sahebxalsa3ada

    sahebxalsa3ada New Member

    Joined:
    Sep 23, 2014
    Messages:
    3
    Hello,

    Is there anyway I could use the username of a logged in member in a link ? For example, a link is shown to a member and I want the url to be Http://www.google.com/*username*

    Could this happen in anyway?

    Thanks in advance!
  2. thehpmc

    thehpmc aMember Pro Customer

    Joined:
    Aug 24, 2006
    Messages:
    901
    How good is your PHP knowledge?

    Basically you can obtain username as a PHP string using the amLite function and then all you need is to use the echo command in a php page.
    PHP:
    echo "http://www.google.com/$username"
  3. sahebxalsa3ada

    sahebxalsa3ada New Member

    Joined:
    Sep 23, 2014
    Messages:
    3
    Thanks for your help. I'm really an experienced HTML and CSS developer but my PHP knowledge is kinda of low to medium! Can you help me through Skype or private message? I'm also ready to pay you if needed :)!
  4. thehpmc

    thehpmc aMember Pro Customer

    Joined:
    Aug 24, 2006
    Messages:
    901
    Can you explain EXACTLY what you are trying to achieve. Somehow I don't think you are really trying to link to a folder on Google named after your members username!

    Sorry currently don't have Skype facility enabled here at the moment. You can send PM if you prefer not to publish sensitive details but I prefer open forum as it leaves discussion open for others to offer input or even learn from suggestions made.

    Please be aware I have learnt my way around aMember, and also PHP scripting, but mostly by hands on experience, and an enquiring mind. I would never claim to be an 'expert' with either but willing to help if possible.
  5. sahebxalsa3ada

    sahebxalsa3ada New Member

    Joined:
    Sep 23, 2014
    Messages:
    3
    Well, the google link was just an example. What I want to do is to let members download a file from another website using link.com/username after buying a subscription! I really do think what I want is easy but I just need a hint because I haven't dealt with such software before.

    Thanks!
  6. thehpmc

    thehpmc aMember Pro Customer

    Joined:
    Aug 24, 2006
    Messages:
    901
    Sorry I still cannot see what you are trying to achieve. If you link to another site using the link
    Code:
    www.othersite.com/username
    you will receive a 404 Page not Found error unless that other site has directories named after every username you have.

    But to give you an idea of code required within a file with a php extension
    PHP:
    require_once '/home/myusername/public_html/amember/library/Am/Lite.php';  //Note MUST be first line of script and path changed to suit your site
    $username=Am_Lite::getInstance()->getUsername();
    Now in the body of your page where you want the link
    PHP:
    <?php echo  "<a href=http://www.yourothersite.com/$username>link to</a> "?>
    As said above the 'require' link needs to be correct for your site.

    Please remember this is untested but should give you a starting point for what you seem to be trying to achieve.

Share This Page