WordPress.org

Ready to get started?Download WordPress

Forums

Get author nickname from author ID ? (4 posts)

  1. Anonymous
    Unregistered
    Posted 9 years ago #

    I want to turn the "author=#" field from the GET http call into an author name ... any ideas ?
    In other words, I have:
    http://mysite/index.php?author=2
    and I want to change that "2" into "johnny boy", or whatever.
    I need to do this outside the loop.
    cheers,
    e

  2. Kafkaesqui

    Posted 9 years ago #

    get_userdata($author);
    If that fails, try:
    get_userdata($_GET['author']);
    Then you can assign user/profile data this way:
    $name = $profile->user_firstname . ' ' . $profile->user_lastname;
    Or perhaps:
    $name = $user->user_nickname;

  3. Anonymous
    Unregistered
    Posted 9 years ago #

    cool beans ...
    that worked great.

  4. e-head
    Member
    Posted 9 years ago #

    Actually, this worked and then stopped working ... I hadn't tested with many different authors yet I guess.

    Try this though ... so far it is working:

    $myuser = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = '$author'");
    $nick = stripslashes($myuser->user_nickname);

    author needs to be passed as a GET variable, or somehow needs to be set. This is the author's ID, or number, I think.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.