my theme currently uses the wp_update_user function to update a set of user metas.

I created to some new user meta fields that I would like to include in the existing wp_update_user. The function updates the meta fields based on form elements, like this...

$_POST['form']['ID'] = $userdata->ID;
$_POST['form']['jabber']  = $_POST['address']['country']."**";
$_POST['form']['jabber'] .= $_POST['address']['state']."**";
$_POST['form']['jabber'] .= $_POST['address']['address']."**";
$_POST['form']['jabber'] .= $_POST['address']['city']."**";
$_POST['form']['jabber'] .= $_POST['address']['zip']."**";
$_POST['form']['jabber'] .= $_POST['address']['phone'];

if( ( $_POST['password'] == $_POST['password_r'] ) && $_POST['password'] !=""){
            $_POST['form']['user_pass'] = $_POST['password'] ;
        }

    wp_update_user( $_POST['form'] );

$ADD = explode("**",$userdata->jabber);

The wp_update_user function is using $_POST['form'] as the parameter to update the user.

Along with this function there is a form with the different form inputs with names, such as this, address[phone] which is the $_POST['form']['jabber'] .= $_POST['address']['phone']; portion of the above code.

The sample form input element is this...

<input type="text" name="address[phone]" value="<?php echo $ADD[5]; ?>" />

I was thinking that to create a new user field and include it into the existing wp_update_user function being used, all I would have to do is create the input element like this...

<input type="text" name="form[new_user_field]" value="<?php echo $_POST['form']['new_user_field']; ?>" />

and then add a line of code to the function values like this...

$_POST['form']['new_user_field'] .= $_POST['form']['new_user_field'];

But...after submitting the form that the function belongs to, my newly inputted value isn't saved in the new user meta field.

Is there a way to include my new user meta field into the existing wp_update_user? Can someone tell me what Im doing wrong?

Thanks a lot

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top