Skip to content

Instantly share code, notes, and snippets.

@mlbd
Created January 10, 2016 18:39
Show Gist options
  • Save mlbd/58b2122b596ef04dd853 to your computer and use it in GitHub Desktop.
Save mlbd/58b2122b596ef04dd853 to your computer and use it in GitHub Desktop.
add_action( 'show_user_profile', 'add_extra_social_links' );
add_action( 'edit_user_profile', 'add_extra_social_links' );
function add_extra_social_links( $user )
{
?>
<h3>New User Profile Links</h3>
<table class="form-table">
<tr>
<th><label for="business_sector">Business Sector</label></th>
<td><input type="text" name="business_sector" value="<?php echo esc_attr(get_the_author_meta( 'business_sector', $user->ID )); ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="phone_number">Phone Number</label></th>
<td><input type="text" name="phone_number" value="<?php echo esc_attr(get_the_author_meta( 'phone_number', $user->ID )); ?>" class="regular-text" /></td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'save_extra_social_links' );
add_action( 'edit_user_profile_update', 'save_extra_social_links' );
function save_extra_social_links( $user_id )
{
update_user_meta( $user_id,'business_sector', sanitize_text_field( $_POST['business_sector'] ) );
update_user_meta( $user_id,'phone_number', sanitize_text_field( $_POST['phone_number'] ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment