Jul
5th

WordPress Hacks - adding additional User Fields

Happy New Year! Marketing Technology finds and reports on the latest technology that will enable your business to effectively market to your audience, for acquisition or retention strategies. Subscribe now the Marketing Technology Blog RSS feed or to the Marketing Technology Email to have new content sent directly to your inbox. You'll also find my other business blog helpful, Social Media Domination.

I’m rewriting most of WordPress on another site. One of the things I’m finding with WordPress is that all of the functionality is very robust as long as it’s outside of the Admin panel. For ResortPub, I’m looking to make the experience for the blogger as fun as for the reader. The Administration of Wordpress is just not fun. Basics such as customizing the style of the panel and adding additional Author fields can be frustrating. So… I spent some late nights following the code and found the hack!

If you’d like to add some additional User Fields, there are 4 files that you need to edit. In this example, I want to add a field for the user to put an image of themselves so that I can put it on each of their posts. I’m calling the field ‘imageurl’.

  1. Registration-functions.php, ~line 98. This will add the field to the user metatable data: update_usermeta( $user_id, 'imageurl', $imageurl );
  2. Admin-functions.php, ~line 391. This will ensure that the file has an http:// path.if (isset ($_POST['imageurl'])) {
    $user->imageurl = wp_specialchars(trim($_POST['imageurl']));
    $user->imageurl = preg_match(’/^(https?|ftps?|mailto|news|gopher):/is’, $user->imageurl) ? $user->imageurl : ‘http://’.$user->imageurl;
    }
  3. Profile.php, ~line 89. Add the field to the Profile Page.
  4. user-edit.php, ~line 154. Adds the field to the User Edit page.

Happy Wordpress hacking!

RSS feed | Trackback URI

1 Comment »

Comment by Jim
2007-09-26 11:25:03

Very cool - Thanks! But do you know a way to extend the fields in the comments? I’m just now learning my way around WP and I can’t find a way (or a plug-in, for that matter!)
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary. If I don't post them I will reply personally to let you know why.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
Great debate, criticism and colorful commentary is always appreciated and approved!