• well i didnt get any responses last time so let me explain this a little more.
    im just starting to learn php so i need a little help with it. i added a function to the template-functions-author.php file called the_author_image_url. the function works fine by itself. now what i need some php that says if the function does not contain a value, then do nothing. if it does then display the image. ive tried rewriting it a few different ways but im not doing it right. im sure one of you can write it out in a minute. thanks for any help you can give me.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’m a little confused by “does not contain a value”. Do you mean a function’s attributes? If so, try something like this…
    function the_author_image_url( $att = NULL ) {
    if( ! is_null( $att ) ) {
    // do image stuff, $att was set
    }
    }

    I’m not sure if that’s what you meant. Let me know! ??

    oops, that was me… not logged in. ??

    I think he means if there is no authors image.

    Thread Starter esgaroth

    (@esgaroth)

    actually the function is allready defined in the template-functions-author.php file. the function gets an url that the user has entered into the database. but not all users have entered an url. the function looks like this:

    function the_author_image_url() {
    global $id,$authordata; echo $authordata->user_image_url;
    }

    i need to call the function in a way that it will not output anything if there is nothing in the database to return.

    Ah, try this then:
    function the_author_image_url() {
    global $id,$authordata;
    if( ! is_null( $authordata->user_image_url ) && trim( $authordata->user_image_url ) != "" ) {
    echo $authordata->user_image_url;
    }
    }

    Should work.

    Thread Starter esgaroth

    (@esgaroth)

    that works perfectly, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘help with some php’ is closed to new replies.