Skip to content

Instantly share code, notes, and snippets.

@webgurus
Created July 29, 2014 17:11
Show Gist options
  • Save webgurus/cb8be26d8e1ba24d8296 to your computer and use it in GitHub Desktop.
Save webgurus/cb8be26d8e1ba24d8296 to your computer and use it in GitHub Desktop.
Theme function to save custom profile fields created with Advanced Custom fields
// SAVE ACF FIELDS
add_action( 'personal_options_update', 'save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );
function save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta($user_id, 'user_partner_name', ( isset($_POST['user_partner_name']) ? $_POST['user_partner_name'] : '' ) );
update_usermeta($user_id, 'user_address1', ( isset($_POST['user_address1']) ? $_POST['user_address1'] : '' ) );
update_usermeta($user_id, 'user_address2', ( isset($_POST['user_address2']) ? $_POST['user_address2'] : '' ) );
update_usermeta($user_id, 'user_telephone', ( isset($_POST['user_telephone']) ? $_POST['user_telephone'] : '' ) );
update_usermeta($user_id, 'user_website', ( isset($_POST['user_website']) ? $_POST['user_website'] : '' ) );
update_usermeta($user_id, 'user_existing_partner', ( isset($_POST['user_existing_partner']) ? $_POST['user_existing_partner'] : '' ) );
update_usermeta($user_id, 'user_vertical_markets', ( isset($_POST['user_vertical_markets']) ? $_POST['user_vertical_markets'] : '' ) );
update_usermeta($user_id, 'user_type', ( isset($_POST['user_type']) ? $_POST['user_type'] : '' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment