Add Social info to WordPress Profiles

Just a quick snippet for you all as I needed to do this recently for my custom AuthorBox on this site and I didn’t want to include a separate plugin to achieve this.

Just open up your functions.php and add the below…


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Add contact links
function add_contactmethod( $contactmethods ) {
    // Add Twitter
    $contactmethods['twitter'] = 'Twitter';
    // Add Facebook
    $contactmethods['facebook'] = 'Facebook';
    // Add Facebook
    $contactmethods['googleplus'] = 'Google+';
    // Add Facebook
    $contactmethods['skype'] = 'Skype';
    // Remove Yahoo IM

    unset($contactmethods['yim']);
    unset($contactmethods['aim']);

    return $contactmethods;
}

add_filter('user_contactmethods','add_contactmethod',10,1);

I would class the above as pretty self explanatory if your used to WordPress but if not let me try and break it down for you.

We add a custom filter to

user_contactmethods

This lets us intercept the listed options before being processed. We get passed an array which we store in $contactmethods

Array
(
    [aim] => AIM
    [yim] => Yahoo IM
    [jabber] => Jabber / Google Talk
)

From here we can just use normal PHP to create a new element to be stored. We could have used array_push() also but this way looks better to me. Try and keep the Key to one word or a hyphenated word, the value will be the text the end user sees.


1
2
// Add Twitter
$contactmethods[ KEY ] = VALUE;

Notice how I also unset some of the entries? These are just ones that I don’t feel I will need, you can either include these lines or not. Well I hope this helps you understand how to add your own custom contact details to the WordPress Profile pages. What’s that? You need to know how to get them back out aswell… ok then.

Retrieving Author information

Getting the new author meta information is really easy! Check out the official documentation on it afterwards here. If you are within the Loop then you can just use the below


1
2
3
// Get the Googleplus contact information
// This echo's out
the_author_meta( "googleplus");

Or if you need to use this somewhere else then just pass in the User ID along with the meta you want to get


1
2
3
// Get the Googleplus contact information
// This echo's out
the_author_meta( "googleplus", 21 //UserID );

Simple as that folks 😉

Is it time for an upgrade, to Android?

It may be time for an upgrade to an Android phone 😉

Google have just announced their brand new Phone and Tablet, and they beat the Specs of both the iPhone 5 and iPad 4th Gen  whilst still being one of the cheapest devices out there…

Nexus 4 (Phone)
http://www.google.com/nexus/4/

Nexus 10 (Tablet)
http://www.google.com/nexus/10/

Also they innovate and update the operating system a lot faster than iOS who only update once a year. Android have just updated again with more great features, including updates to their Siri killer that now has more useful information, and backed by the Knowledge Graph.

Android 4.2
http://www.android.com/whatsnew/

Google Now (Siri killer)
http://www.google.com/landing/now/

I like the iPhone, but , Android is winning in my opinion. Did I mention that their Maps software won’t take you to the wrong place either and will show you better 3D buildings aswell..

What’s your opinion?