Custom Author Pages

This post has been marked as old. The code might no longer work. Comments have been disabled as this is no longer maintained. Use the search on the right to find a newer tutorial.

Mint Social recently hired me to build a custom author page that they could use for themselves and their clients. The requirements were:

  • Work natively in Thesis (all built in custom_functions.php – no plugins)
  • Allow the author to easily edit his information from the WordPress administration area.
  • Lots of information (and almost all optional): Avatar, bio written in HTML, email author link, author’s address and map…and links to any social networks the author uses (we have about 35 built into the system)

If you click on my name under this post’s title, you can see the end result.

While I can’t provide you with the exact code we used, I can show you the tutorials I’ve written that accomplish each part of this.

First, there’s two custom options pages:a site-wide one for the Google Maps API key,  and an author-specific one that contains all the author’s profile information. Each person who logs in will see their own version of this page.

Here is my tutorial on Custom Options Pages. This tutorial actually walks you through setting up a site-wide one. To make a user-specific one, there’s a few things you’ll have to do differently:

  • The add submenu page line should be changed to
    add_submenu_page('users.php', 'Author Details', 'Author Details', 'edit_posts', 'author-details', 'author_details_admin');
    As the Codex explains, this adds it as a submenu to the Users menu and gives access to anyone who has permission to edit posts (so Authors).
  • Instead of using update_option(), which updates a site-wide variable, you’ll use update_usermeta(), which links the variable to the user. That way, the field “Twitter ID” is linked to the user who inputs it, and doesn’t show up on other users’ profiles. See update_usermeta page in the Codex for information on how to use it.
  • Likewise, when retrieving the variables to display on the custom author page, you’ll use get_usermeta() rather than get_option().

So, you’ve created two options pages: Author Details and Google Maps API Key. Now you need to code the actual author page that uses these pages. Some helpful hints:

  • To stick something on the author page, use the hook thesis_hook_archive_info().
  • If you had multiple fields for the address in the options page like I did (Address Line 1, Address Line 2, City…) combine them all into one variable like this:
    $fullAddress = $address . ' ' . $address2 . ' ' . $city . ', ' . $state . ' ' . $zip;
  • Use the Gravatar tutorial to add the author’s avatar.
  • Use the Google Maps tutorial to add a map (use the $fullAddress variable you made above)
  • For the HTML bio, we originally had a box on the Author Details option page that allowed the author to write it. The client then requested we use an actual WordPress post so that the authors would have at least one post, and they’d be able to use the Visual editor to write their profile. So now in the option page we ask for the Post ID they want to use as their profile. Pick whichever method you prefer.

I’m sorry I can’t be more helpful and provide the actual code, but my client hopes to sell this solution. Hopefully you’ll be able to hack your own custom author page together.

If you do, please share it in the comments!

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. Brainerd Listings says

    Sweet tutorial! I've already made a db bookmark and will be sure to digg it too! Lot's of help on this unique feature. Thanks for sharing.

  2. Matt O'Brien says

    You did a great job Bill. Looking forward to working with you on upcoming WordPress Thesis projects!

  3. Joshua says

    Hey there, just trying to get this to work and I’ve received an error:

    “Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘author_details_admin’ was given in /home/joshuadn/public_html/growthbusters/wp-includes/plugin.php on line 395”

    My code looks like this:

    add_action(‘admin_menu’, ‘thesis_custom_add_page’);

    function thesis_custom_add_page() {

    add_submenu_page(‘users.php’, ‘Author Details’, ‘Author Details’, ‘edit_posts’, ‘author-details’, ‘author_details_admin’);

    // add_theme_page(‘More Options’, ‘More Options’, ‘edit_themes’, ‘more-options’, ‘more_options_admin’);

    }

    Did I mess something up? The “Author Details” link appears under the user menu, but that error is what I get when I click on it…

    Thanks!
    Joshua

    • Joshua says

      Oops! Got it, I forgot to update the function name to author_details_admin! Silly me…

      I’m having some weird server security issues now, I can’t submit my custom_functions in the wordpress editor without getting a 404 error (I’ve been editing it directly via ftp). I had this issue before with posts and pages that had a certain combination of words and I had to contact my host directly to have them add the word ‘from’ on their exceptions list. Weird stuff. Have you had any similar issues with this code? I’m hoping I might get a clue as to which combination of phrases or which word is cause this issue.

      Anyway, Bill, great tutorial! I’ve figured it out and now I just need to build my custom author pages…

      Cheers,
      Joshua

      • Bill Erickson says

        I’ve never seen that issue before. Sounds like something you’ll need to ask the host about :/