Skip to content

Instantly share code, notes, and snippets.

@FerFuego
Created July 21, 2020 17:47
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 FerFuego/86b745450382f454ced57d1f82aaab90 to your computer and use it in GitHub Desktop.
Save FerFuego/86b745450382f454ced57d1f82aaab90 to your computer and use it in GitHub Desktop.
Example update user meta ACF
$user_id = wp_get_current_user()->ID;
update_user_meta( $user_id, 'first_name', $_POST['user_firstname'] );
update_user_meta( $user_id, 'last_name',$_POST['user_lastname'] );
update_user_meta( $user_id, 'linkedin', $_POST['user_linkedin'] );
update_user_meta( $user_id, 'facebook', $_POST['user_facebook'] );
update_user_meta( $user_id, 'instagram', $_POST['user_instagram'] );
update_user_meta( $user_id, 'twitter', $_POST['user_twitter'] );
update_user_meta( $user_id, 'biography', $_POST['user_description'] );
update_user_meta( $user_id, 'education', $_POST['user_education'] );
//json of [specialties, subspecialties]
$bb_specialties = json_decode(stripslashes($_POST['user_specialty']));
update_user_meta($user_id, 'bb_specialties', count( $bb_specialties ), false);
$i = 0;
foreach( $bb_specialties as $bb_sp) {
update_user_meta($user_id, 'bb_specialties_'.$i.'_specialty', $bb_sp->specialty, false);
update_user_meta($user_id, 'bb_specialties_'.$i.'_subspecialty', $bb_sp->subspecialty, false);
$i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment