Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add new Google+ field to WordPress profiles
* Add Google field to WordPress profile
* Kudos to Justin Tadlock
// Display the new field
function werewp_googleplus_field( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<th><label for="googleplus">Google +</label></th>
<input type="text" name="googleplus" id="googleplus" value="<?php echo esc_attr( get_the_author_meta( 'googleplus', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your Google+ profile ID</span>
<?php }
add_action( 'show_user_profile', 'werewp_googleplus_field' );
add_action( 'edit_user_profile', 'werewp_googleplus_field' );
// Save Google+ field
function werewp_save_googleplus_field( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta( $user_id, 'googleplus', $_POST['googleplus'] );
add_action( 'personal_options_update', 'werewp_save_googleplus_field' );
add_action( 'edit_user_profile_update', 'werewp_save_googleplus_field' );
// Add paragraph with link to Google Profile, by inserting the function werewp_author_bio in your template files
function werewp_author_bio() {
if ( get_the_author_meta( 'googleplus' ) ) { ?>
<p class="googleplus">
<a rel="author" href="<?php the_author_meta( 'googleplus' ); ?>/about" title="Circle me on Google+">Circle me on Google+</a>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.