Support » Everything else WordPress » WordPress Inside Joke Prank

  • Resolved sanchit


    I want some piece of code that will see if the person who posted a post is author_ID #3 and I want it to display Ricky Martin instead of his name. I was just looking around various things but I can’t figure out how to make the_author() not return anything. Maybe if someone can point that out I’ll see how I can make it return but not echo the name.

    <?php if (the_author()=="User Name" && $user_ID!=3 && $user_level > 0 && ($user_ID=1 || $user_ID=7 || $user_ID=5 || $user_ID=2 || $user_ID= 4)){ echo "<a href=".get_bloginfo('template_directory')."/images/ricky_martin.jpg>Ricky Martin</a>"; } else { the_author_posts_link(); }?>

    This code seemed to work but it only works for the first post. The_author has no parameters.. I just found that the_author(”,false) somewhere and tried it and it worked.

    Do you guys get what I am trying to do here? Help is most appreciated. Making users 2,4,5 and 7 be the only people to see Ricky Martin and it only says Ricky Martin if someone is logged on AND of course uID#3 doesn’t know or suspect anything.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Can someone tell me where the_author and other function are written so that I can solve this on my own? Which file in which folder?


    Dang, I don’t know the answer, but that is pretty funny stuff right there. Making some users see “Ricky Martin” every time your buddy posts, lolz.

    well… no thanks to everyone here but I found the_author() function with the depreciated functions in wp-includes/author-template.php I am going to mess around it over there.

    I still don’t know why when I put in that code it only works for the first post by that author on a page.. :\

    global $user_level; global $user_ID; get_currentuserinfo();
    //echo $user_ID;
    if ($user_ID==2 || $user_ID==7 || $user_ID==4 || $user_ID==5)
    if (get_the_author_login()=="PersonsLoginName")
    { echo "<a>Ricky Martin</a>"; }
    else { the_author_posts_link();  }
    else { the_author_posts_link();  }

    I think this works fine.. the problem with the earlier code might have been the fact that in the $user_ID=watever it should be ==

    Anyways, enjoy.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    the_author isn’t deprecated. And all you have to do is this, in your theme, instead of “the_author()”:

    if ($author=="Username") echo "Ricky Martin";
    else echo $author;

    Another way, which would work even with the_author or author_posts_link or anything else is to use a filter on the_author. You’d add this to your theme’s functions.php file:

    function joke_author($author) {
    if ($author == 'Username') return 'Ricky Martin';
    else return $author;

    Adding the user_id stuff should be obvious, you’re just going to add an “&& ($user_ID=1 || $user_ID=2)” stuff to the if statements.

    I realized that I needed a get_the function cause they don’t echo but they just return the values. Once I got to see the actual functions for my own in the author-template.php file everything became clear as to how I could use everything.

    You’re making the same mistake as me! $user_ID==1 😛

    Thanks for the input. Problem is solved though. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WordPress Inside Joke Prank’ is closed to new replies.