0

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

1

I would use the update_user_meta function instead.

  • Thanks Joseph! I use that function a lot in my theme. I dont know why I didnt think of using it now. Thanks again! – user1893 Dec 1 '11 at 20:55
  • Glad I could help! It's always the little things that get us… – Joseph Leedy Dec 2 '11 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.