July 19th, 2009
Last night there was a discussion as to what could be achieved today as part of a “WordHack” session at WordCamp UK and SimonD tweeted that he would like to be able to add extra user meta fields to the back end user profile page easily.
I tweeted back that it was already easy and so here is the proof of concept code which shows you:
- How to add a user meta field to the page
- How to process the new value when it is updated.
These can the been displayed on the front-end using the standard template tags get_the_author_meta() and the_author_meta()
<?php
/*
Plugin Name: PJW User Meta
Plugin URI: http://blog.ftwr.co.uk/archives/2009/07/19/adding-extra-user-meta-fields
Description: Allows users to configure some random extra meta value.
Author: Peter Westwood
Version: 0.02
Author URI: http://blog.ftwr.co.uk/
Use of the frontend as get_the_author_meta('something') or the_author_meta('something')
*/
class pjw_user_meta {
function pjw_user_meta() {
if ( is_admin() )
{
add_action('show_user_profile', array(&$this,'action_show_user_profile'));
add_action('edit_user_profile', array(&$this,'action_show_user_profile'));
add_action('personal_options_update', array(&$this,'action_process_option_update'));
add_action('edit_user_profile_update', array(&$this,'action_process_option_update'));
}
}
function action_show_user_profile($user)
{
?>
<h3><?php _e('Other Contact Info') ?></h3>
<table>
<tr>
<th><label for="something"><?php _e('Something else'); ?></label></th>
<td><input type="text" name="something" id="something" value="<?php echo esc_attr(get_the_author_meta('something', $user->ID) ); ?>" /></td>
</tr>
</table>
<?php
}
function action_process_option_update($user_id)
{
update_usermeta($user_id, 'something', ( isset($_POST['something']) ? $_POST['something'] : '' ) );
}
}
/* Initialise outselves */
add_action('plugins_loaded', create_function('','global $pjw_user_meta_instance; $pjw_user_meta_instance = new pjw_user_meta();'));
?>
Enjoy!
Updated to correctly use the $user/$user_id passed to the actions rather than the global $user_id
Posted in Development, Tutorials, WordPress | Read 19 Comments
May 26th, 2009
I was reminiscing today on what the world was like when I released my WordPress version check plugin back in 2005.
What a different world it was, upgrading WordPress took time and people just didn’t bother even though new versions which contain security fixes had been released.
Now we are just about to get WordPress 2.8, people can upgrade with the click of a button and there hasn’t needed to be a security release for WordPress 2.7 how things change.
In celebration of this I have decided to take down the web-service which supported the plugin and have started the shutdown process by changing the message returned to point to this blog post. So please un-install the plugin and rely on the notification that has been built in to WordPress for a few releases now.
Oh and don’t forget if your one of those people who has been ignoring these messages and are still running v1.5.2 (yes you know who you are) then please upgrade.
Posted in Development, Security, WordPress | Comment on this post
May 26th, 2009
I had a request recently for help on using my Query Child Of plugin to create a page template to show the grandchildren of a page as well as a number of people asking for better examples on how to use my plugin in general to just list the children of a page.
I am now happy to announce that I can provide these examples and have updated the plugin documentation on in the WordPress plugin directory to match as well.
Read the rest of this entry »
Posted in Development, Tutorials, WordPress | Read 2 Comments
May 25th, 2009
Jane asked -
“I’m nowhere near my iMac, and won’t be for weeks. I need to backup my iPhone onto my MacBook Pro or external hard drive today. How?!”
To which the answer is, suprisingly, use iTunes.
It turns out that once you have connected your iPhones to iTunes on another Mac you can just right click on the device and select backup like so:

Hopefully this will help other people in a similar situation in the future.
Posted in Technology, Tutorials | Comment on this post
May 11th, 2009
Just went to check my ohloh stats today to find I have reached a milestone in my work as a WordPress lead developer.
According to there counts I have made 500 commits to the trunk section on the WordPress subversion repository.

Posted in Development, WordPress | Read 2 Comments
May 9th, 2009
Last night I was setting up my new Time Capsule and suddenly lost access to all my remote servers over ssh.
All I got was the following error upon connection ’ssh_exchange_identification: Connection closed by remote host” and everything I searched around the web implied this was to do with too many connections to the server or incorrect reverse dns setup.
Neither or these issues applied to me and for a while I was stumped until it dawned on me that the Time Capsule had a much better NAT implementation it in with specific handlers for different protocols and I have all my servers configured to accepting incoming ssh connections on a non-standard port so as to reduce the number of ssh probe attacks. Once I opened up a different port that isn’t used for other protocols by default it all burst back into life.
Hopefully, this will help someone who encounters the same problem in the future!
Posted in Technology | Read 3 Comments
April 9th, 2009
Yesterday I put the finishing touches to my new Blog Minder plugin.
This plugin will remind you if you have not posted something new on your blog recently enough based on a threshold you set on a per-user basis.

Ideal for making sure a site keeps getting updated with fresh content on a regular basis.
Hopefully it is going to make me post more often here too!
Posted in WordPress | Join the discussion
March 20th, 2009
By popular request I have updated my Query Child Of plugin to support limiting the number of child pages returned (and to support the ability for this limit to be offset).
The plugin is also now hosted on WordPress.org Extend as PJW Query Child Of and I have also writen up some example php code so as to make it really easy to use!
Posted in Asides, Development, WordPress | Comment on this post