WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] is there a function like update_usermeta to update wp_user table? (6 posts)

  1. StrangeAttractor
    Member
    Posted 5 years ago #

    I'm trying to fix a bug in the Register Plus plugin. It uses the update_usermeta function to create and update extra fields in the registration form and the user profile.

    The problem is that it uses update_usermeta function for the user_url (website on the profile). But in fact user_url is stored in the wp_user table, not in the wp_usermeta table.

    As a result, you can't update any user website that has been entered at registration.

    So I'd like to know if there's a WordPress function like update_usermeta that writes to wp_user table instead of the wp_usermeta table.

    And if so, how do you use it?

    Much thanks, haven't been able to find what I'm looking for in the Codex.

  2. StrangeAttractor
    Member
    Posted 5 years ago #


  3. Justin Tadlock
    Member
    Posted 5 years ago #

    update_usermeta should work for this:

    update_usermeta( $user->id,'user_url','http://someurl' );

    But, if it doesn't, maybe check out wp_update_user:
    http://codex.wordpress.org/Function_Reference/wp_update_user

  4. StrangeAttractor
    Member
    Posted 5 years ago #

    Thanks! The link you provided is what I was looking for, so I'll see if that works.

    The example you give for update_usermeta is what the Register Plus script uses, but as far as I can tell, WordPress's native register / profile scripts store user_url in the user table, not in the usermeta table.

  5. Justin Tadlock
    Member
    Posted 5 years ago #

    Maybe something like this then:

    wp_update_user( array( 'user_url' => 'http://some-url' ) );
  6. StrangeAttractor
    Member
    Posted 5 years ago #

    Thanks so much, greenshady. This information was difficult to find, and I had some trouble with it, because my understanding of arrays is not very good.

    Anyway, I got it to do what I wanted -- fix a bug in the Register Plus plugin that was writing the website to the wrong table (usermeta instead user table), and thus making it impossible to update the website by editing the user profile.

    I posted my correction of the bug in this thread:
    http://wordpress.org/support/topic/246570

    (Actually, if you can see any problems -- such as security issues -- with what I posted, please let me know...)

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic