The MU forums have moved to WordPress.org

copy register information to my datebase (2 posts)

  1. jasontower
    Member
    Posted 15 years ago #

    I want to make a copy of user ID and name into my own database when new user registers. So I edit the register_new_user function in wp-login file.

    ...
    ...
    function register_new_user($user_login, $user_email) {
    ...
    ...
    wp_new_user_notification($user_id, $user_pass);
    // my code starts.
    $con = mysql_connect("localhost","mydatabase","mypasswd");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("test", $con);
    $sql="INSERT INTO Registered_User_Test (ID, Name, Email)
    VALUES
    ('$user_id','$user_login','$user_email')";
    if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
    mysql_close($con);
    //my code ends.
    return $user_id;
    }
    But it doest work.
    Anyone who knows how to do that?
    Thanks

  2. tim.moore
    Member
    Posted 15 years ago #

    You should look into using a plug-in to do this. Inside the plug-in, you can hook into the wordpress function when creating a new user. Take a look at http://codex.wordpress.org/Creating_Tables_with_Plugins for more.

About this Topic

  • Started 15 years ago by jasontower
  • Latest reply from tim.moore