Support » Alpha/Beta/RC » 2.0 is_author() help

  • Resolved badrad



    I am using WordPress 2.0 RC1 and developing my first WordPress site. Thanks in advance for any help.

    In my sidebar I have a list of all authors, and clicking on one of them properly brings up However, at the top of the list of their posts, I want to have a blurb about them. At first I was going to pull the information from the user profile, but none of the methods to do so in the Author Templates section of the Codex seem to work in 2.0. I tried posting about that:

    But no is responding. So I thought, screw it, I’ll just use is_author() and code the profiles directly into the template. Here is my problem though. While is_author() is working, I can’t pass it any parameters. According to the Conditional Tags page in the Codex, I can pass it the author number, nickname, or nicename. But none of those are working. It only works if I use no parameters.

    Was the functioning of is_author() changed in 2.0? Is this perhaps a bug? Help?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The issue with the is_author() parameter does appear to be a bug. In any case, does something like the following work for you:

    $author = get_userdatabylogin($_GET['author_name']);
    echo $author->nickname;

    EDIT: is_author() bug reported

    Thanks for confirming and reporting that is_author() bug. Thanks for the code suggestion as well.

    As far as the code you gave, no it is not working. I tried it both in and out of the loop. I tried it as you gave it to me, and even triedto replace ‘author_name’ with the name, login, you name it.

    I came up with something, but I still think its jumping through a lot of hoops. Since the template tags do work within the loop, if I make a count variable that counts out the number of posts, I can make a section at the top of the page if I wrap it in an if statement that checks to see that the count variable is at 1 so that we are before our first post.

    With this I’d be able to do what I want, except for one thing. The author tags, such as the_author_firstname();, echo their contents and do not return them to PHP. They also dont accept a parameter to return the results to PHP like some tags do. So Id have to jump through an additional hoop of using output buffering to capture the echo to a variable.

    Should the code you gave me be working? Should I try something else?

    I guess I should just wait for the is_author() bug to be fixed, huh? I sure hope they fix it for WP 2.0. Even then I’d still have to code the author information into the template rather then pulling it from the profile though.

    Ah! It’s driving me crazy 🙂

    RE: ‘author_name’

    There are two options to my code above: $_GET['author_name'] works off login name, and $_GET['author'] takes the user ID #.

    $_GET is a PHP ‘superglobal’ that holds variables passed through a query string (i.e. ?author_name=kaf). These *should* work when one is on an author query-type page. A way to test is to insert the following in your template:

    echo 'author: ' . $_GET['author'] . '<br />';
    echo 'author_name: ' . $_GET['author_name'] . '<br />';

    Then you’ll know A. if $_GET is working, and B. which one is passed on your author pages.

    RE: the_author_firstname()

    Since 1.5 there’s been an effort to provide versions of (nearly) all template tags which return instead of echo or display their output. So try using this in your code:


    RE: is_author() bug

    I rarely find the need to wait for a fix, as there’s (almost) always a solution or workaround out there, somewhere…

    The $GET superglobal is definitely working, this:
    echo 'author_name: ' . $_GET['author_name']
    Works like a charm. Since this:
    $author = get_userdatabylogin($_GET['author_name']);
    echo $author->nickname;

    Isn’t working, I guess its the get_userdatabylogin function that isnt working like we want it too.

    But get_the_author_firstname() works like a charm! With this, I can do exactly what I want. I’ll create a variable to count out the number of posts, and use that variable to post a section about the author before the first post. Not only can I pull information directly from the profile, I can use the name in PHP to output some special suff I want to for each author.

    Thanks A LOT Kafkaesqui. I really, really apreciate the help.

    Someone should go through the codex and make notes on each tag that has the get_ prefix avaiable. When I’m done with my site I may do it 🙂

    $author = get_userdatabylogin($_GET[‘author_name’]);
    echo $author->nickname;

    I’m using this in archive.php in WordPress 2.0, and it won’t return anything if the nickname has more than one word.

    RobotDan: maybe this will work for you:

    $author = get_userdatabylogin(get_the_author_login());

    I can’t find a way to get any method mentioned above to return author data in 2.0.1. Help?

    This is what I use:


      <?php wp_list_authors(‘optioncount=0&show_fullname=1&exclude_admin=0&hide_empty=1’); ?>

    Thanks. The wp_list_authors() was working fine for me.

    I was looking for a way to display the description info.

    I discovered this works in 2.0.1:

    $curauth = get_userdata(intval($author));

    echo $curauth->description;

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘2.0 is_author() help’ is closed to new replies.