Skip to content

Instantly share code, notes, and snippets.

@wbxpress
Created September 9, 2017 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbxpress/4bd84fe17f9d9d270e249d7b10383ac1 to your computer and use it in GitHub Desktop.
Save wbxpress/4bd84fe17f9d9d270e249d7b10383ac1 to your computer and use it in GitHub Desktop.
add_action( 'show_user_profile', 'wbxp_profile_fields' );
add_action( 'edit_user_profile', 'wbxp_profile_fields' );
function wbxp_profile_fields( $user ) {
?>
<h3>Social Sites</h3>
<table class="form-table">
<tr>
<th><label for="twitter">Twitter</label></th>
<td>
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" /><br />
<span class="description">Your Twitter Username</span>
</td>
</tr>
<tr>
<th><label for="twitter">Facebook</label></th>
<td>
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" /><br />
<span class="description">Your Facebook Profile URL</span>
</td>
</tr>
<tr>
<th><label for="twitter">Linkedin</label></th>
<td>
<input type="text" name="linkedin" id="linkedin" value="<?php echo esc_attr( get_the_author_meta( 'linkedin', $user->ID ) ); ?>" /><br />
<span class="description">Your Linkedin Profile URL</span>
</td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'wbxp_save_profile_fields' );
add_action( 'edit_user_profile_update', 'wbxp_save_profile_fields' );
function wbxp_save_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
update_user_meta( $user_id, 'linkedin', $_POST['linkedin'] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment