WordPress.org

Ready to get started?Download WordPress

Forums

Passing a username through a URL (7 posts)

  1. andytford
    Member
    Posted 6 years ago #

    How do I pass the username through a URL? This is specifically used to get to a third party site where both usernames have to be sync'd.

    I am just placing this in the HTML (and sidebar as a text widget). An example would look like this:

    Ex: http://www.domain.com/login.php?user_id=jsmith

    I just don't know how to write the code that would grab the username and place it at the end of the URL. I'd be grateful for just a simple direction that I can Google.

    Thanks in advance!

  2. haochi
    Member
    Posted 6 years ago #

    <?php
    global $user_login;
    get_currentuserinfo();
    if(!empty($user_login)){
    echo "<a href='http://www.domain.com/login.php?user_id=".$user_login."'>BLAH</a>";
    }
    ?>

    not tested.

  3. andytford
    Member
    Posted 6 years ago #

    haochi,

    This isn't displaying as a link. It shows text that reads:

    BLAH"; } ?>

    I attempted a combination of "'s and ''s to see if it made any difference. I need to research the syntax, but thanks for the help.

  4. whooami
    Member
    Posted 6 years ago #

    <?php
    //global $user_login;
    //get_currentuserinfo();
    $user_login = "whoo";
    if(!empty($user_login)){
    echo "<a href='http://www.domain.com/login.php?user_id=".$user_login."'>BLAH</a>";
    }
    ?>

    tested from the cli, works fine.

    theres nothing wrong with the syntax he provided. there are no php errors within that.

  5. whooami
    Member
    Posted 6 years ago #

    meh, I was askimeted. There is nothing wrong with the syntax in that, and it works properly.

  6. andytford
    Member
    Posted 6 years ago #

    Would there be an issue with placing it inside of a Text widget that would cause that?

  7. whooami
    Member
    Posted 6 years ago #

    Would there be an issue with ...

    I dont have a clue about that, sorry. I dont use widgets of any kind. Im old school :P

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.