我正在使用下面的功能,它适用于我的电话和地址字段。我似乎无法更改电子邮件。。。知道我做错了什么吗?
function um_modifications_callback() {
// Ensure we have the data we need to continue
if( ! isset( $_POST ) || empty( $_POST ) || ! is_user_logged_in() ) {
// If we don\'t - return custom error message and exit
header( \'HTTP/1.1 400 Empty POST Values\' );
echo \'Could Not Verify POST Values.\';
exit;
}
$user_id = get_current_user_id(); // Get our current user ID
$um_val = sanitize_text_field( $_POST[\'first_name\'] ); // Sanitize our user meta value
$um_user_email = sanitize_text_field( $_POST[\'user_email\'] ); // Sanitize our user email field
$phone = $_POST[\'phone\'];
$address = $_POST[\'address\'];
$email = $_POST[\'user_email\'];
update_field(\'phone\', $phone, \'user_\'.$user_id);
update_field(\'address\', $address, \'user_\'.$user_id);
update_user_meta( $user_id, \'first_name\', $um_val ); // Update our user meta
wp_update_user( array(
\'ID\' => $user_id,
\'user_email\' => $email,
) );
exit;
}