WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_insert_user : problem while updating : nothing happens (2 posts)

  1. nicolaskern
    Member
    Posted 4 years ago #

    Hi,

    I use the function wp_insert_user() to update user's settings, but I can't get it to work.
    Here is my code :

    include '../wordpress-mu/wp-blog-header.php';
    include '../wordpress-mu/wp-includes/registration.php';
    
    $first_name = htmlentities($_POST['first_name']);
    $last_name = htmlentities($_POST['last_name']);
    $user_email = htmlentities($_POST['user_email']);
    
    $userdata_new = array();
    $userdata_new['user_pass'] = $current_user->user_pass;
    $userdata_new['user_login'] = $current_user->user_login;
    if (!empty($first_name)) $userdata_new['first_name'] = $first_name;
    if (!empty($last_name)) $userdata_new['last_name'] = $last_name;
    if (!empty($user_email)) $userdata_new['user_email'] = $user_email;
    
    wp_insert_user($userdata_new);

    I don't really see why it's not working, I send it an array as it's required, here is an example of my array $userdata_new :

    Array ( [user_pass] => $P$BSOfnh.OWENyzvWb1nxIGIXRn0WM7W/ [user_login] => admin [user_email] => mail@mail.fr )

    Thanks a lot for your help,
    Nicolas

  2. nicolaskern
    Member
    Posted 4 years ago #

    Solved, I was including a php page with an opening of another MySQL connection, for sure it wasn't working...

Topic Closed

This topic has been closed to new replies.

About this Topic