Support » Plugins » update_user_option() Not quite working right.

  • Im in the process of writing a little Profile Plugin to allow for more options to be attached to a registered user, but im having issuse updating email and url of the user.

    update_user_option() does not seem to want to update wp_user table as i thought it would, instead it inserts the option in to wp_usermeta which is fine, but the issuse is that WordPress falls over with user_email being placed in wp_usermeta. It refuses to pull back the users email and in the case of the URL it gets confused into which one to display and update ūüôĀ

    Any ideas how we to just change the feilds in wp_user instead of having update_user_option() add them into the wp_usermeta table?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Registration can occur with just a username and email. Those fields are stored in wp-users

    wp-users stores


    The following data gets added when a user edits his profile

    wp_usermeta stores


    with the meta_keys being


    and the meta data displaying the data for each key.

    BigJohn, i know what is stored in each table within MySQL

    My issuse is that the functions within WordPress dont seem to be updating the correct tables for my plugin.

    update_user_option() is used in profile.php in the backend to update the users email and url and others use update_usermeta() but for some reason update_user_option() wants to place everything in wp_usermetadata

    Im trying to stick to WP functions instead of using MySQL. Otherwise it would be simple!

    Ive bitten the bullet and just used $wpdb->query() and made it insert into the DB myself.

    But i’ve come across a very strange issuse, below is the code im using to update the details of a user.

    $wpdb->query("UPDATE wp_users SET user_url='$_GET[website]' WHERE ID='$_GET[id]'");
    $wpdb->query("UPDATE wp_users SET user_email='$_GET[email]' WHERE ID='$_GET[id]'");
    # update/create usermeta
    $username = explode(' ',$_REQUEST[username]);
    update_usermeta($_REQUEST[id],'last_name',$username[1]); update_usermeta($_REQUEST[id],'user_telephone',$_REQUEST[telephone]);
    update_usermeta($_REQUEST[id],'user_company',$_REQUEST[company]); update_usermeta($_REQUEST[id],'user_addr1',$_REQUEST[address1]); update_usermeta($_REQUEST[id],'user_addr2',$_REQUEST[address2]); update_usermeta($_REQUEST[id],'user_city',$_REQUEST[city]); update_usermeta($_REQUEST[id],'user_postcode',$_REQUEST[postcode]); update_usermeta($_REQUEST[id],'user_country',$_REQUEST[country]);

    Now the user_email and user_url at the top (one’s using $wpdb->query ) will only update if one of the usermeta feilds have been altered. If you just attempt to update the email or url on there own it just ignores it and refuses to update even tho it passes the query!

    This really has got me confused!

    Was curious if you found a resolution to this issue?

    If not, I think I may have found a related thread here that might help:

    BTW, I’m very insterested in your profile plug-in. How is that effort going?

    I basicly ended up writing my own function which would create a nice user object.

    Also there is a sub-object within it with everything from wp_usermeta for that user.

    Ive done it a few times over now :S i dont have the newest version of this at work, but if you want to have a look over the code email me on mark[at] and ill send you what ive done on my new project.


    Um, could this be used to update comments with new account information?

    That is, could I use something like this to edit all comments with a new name, email address, and URI ? I am looking for a way I could update my old comments with my new account information. I have hundred of comments to update, and doing it by hand would be a nightmare. ūüôĀ




Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘update_user_option() Not quite working right.’ is closed to new replies.