Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Created November 17, 2020 05:25
Show Gist options
  • Select an option

  • Save yousufansa/a07872bfcf302882df131c85617f8a30 to your computer and use it in GitHub Desktop.

Select an option

Save yousufansa/a07872bfcf302882df131c85617f8a30 to your computer and use it in GitHub Desktop.
MAS Videos - Store custom user meta values during user registration ( First Name & Last Name )
if ( ! function_exists( 'masvideos_save_custom_user_meta' ) ) {
function masvideos_save_custom_user_meta( $user_id ) {
$nonce_value = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : '';
$nonce_value = isset( $_POST['masvideos-register-nonce'] ) ? $_POST['masvideos-register-nonce'] : $nonce_value;
if ( ! empty( $_POST['register'] ) && wp_verify_nonce( $nonce_value, 'masvideos-register' ) ) {
if ( ! empty( $_POST['first_name'] ) ) {
update_user_meta( $user_id, 'first_name', trim( $_POST['first_name'] ) );
}
if ( ! empty( $_POST['last_name'] ) ) {
update_user_meta( $user_id, 'last_name', trim( $_POST['last_name'] ) );
}
}
}
}
add_action( 'masvideos_created_user', 'masvideos_save_custom_user_meta' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment