WordPress.org

Forums

[resolved] Using update_usermeta in a plugin when user registers (3 posts)

  1. darkfate
    Member
    Posted 7 years ago #

    OK, so what I'm trying to do is add a phone field to the user registration. I've added the field in the registration box, and I want to use update_usermeta to add the phone to the usermeta table. I've been trying to use the user_register actions to put this in. The problem is that I can't get the ID since the user has just registered and isn't logged in. I'm just wondering if there it's possible to get that ID at this point.

  2. darkfate
    Member
    Posted 7 years ago #

    I'm doing this in my plugin:

    function addphone($user_id)
    {
    	global $wpdb, $phone;
    	return update_usermeta( $user_id, 'phone', $phone );
    }
    add_action('user_register','addphone');

    $user_id is returning blank and I don't know why.

  3. darkfate
    Member
    Posted 7 years ago #

    I guess it returns blank, but I realized now that it's going into the database.

Topic Closed

This topic has been closed to new replies.

About this Topic