• Resolved pwpx2

    (@pwpx2)


    Good Morning,

    Can someone guide me where i could find the function(s)/queries that actually do the insert of user data upon registration ? [name, password. email]

    I’m trying to duplicate some of the data to be inserted also in another table, not only in the wp_users

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Good morning!

    To find the functions or queries responsible for inserting user data upon registration in WordPress, you’ll typically need to look into the WordPress core files. Specifically, you’ll want to focus on the registration process within the wp-includes/registration.php file.

    Here’s a general overview of what you’ll find:

    1. wp_insert_user() Function: This function is responsible for inserting a new user into the WordPress database. It’s located in the wp-includes/user.php file. Within this function, you’ll find the core logic for inserting user data, such as username, email, and password.
    2. Hooks and Actions: WordPress provides several hooks and actions throughout the registration process that allow developers to customize or extend the default behavior. For example, the register_new_user action is fired after a new user is registered, and you can hook into it to perform additional actions.
    3. Database Queries: Direct database queries may also be used to insert user data. These queries are typically found within the functions mentioned above or within other related functions in WordPress core files.

    If you’re looking to duplicate user data into another table, you can do so by hooking into the appropriate action or filter and then executing your custom database queries within your theme’s functions.php file or a custom plugin.

    Here’s a basic example of how you might accomplish this:

    function duplicate_user_data_to_custom_table($user_id) {
        global $wpdb;
    
        // Get user data
        $user = get_userdata($user_id);
    
        // Insert data into custom table
        $wpdb->insert(
            'your_custom_table_name',
            array(
                'user_id' => $user->ID,
                'username' => $user->user_login,
                'email' => $user->user_email,
                // Add additional fields as needed
            )
        );
    }
    add_action('user_register', 'duplicate_user_data_to_custom_table');

    Replace 'your_custom_table_name' with the name of your custom table, and adjust the fields you want to insert accordingly.

    Remember to always make changes like this in a safe environment, such as a staging site, and to back up your database before making any modifications.

    If you have any further questions or need clarification, feel free to ask!

    Thread Starter pwpx2

    (@pwpx2)

    Thank you.

    This actually worked but i see something very weird.

    The user_pass string is different on the 2nd table; it’s not the same as the one in the 1st.

    They shouldn’t get generated different, no?

    I believe they are changed because the action is done when they register, but then on the 1st table you do have the option (when you confirm the account/recover basically) set the password. When you register you don’t have any option to actual set your own password. 1st table, the normal wp_users gets the update password eventually, 2nd table, the custom one, gets the default user_pass string before they even set their password.

    Hmm…

    • This reply was modified 6 months, 3 weeks ago by pwpx2.
    Thread Starter pwpx2

    (@pwpx2)

    Where are the functions/hooks to modify the registration page so that user needs to complete and confirm password itself upon registration? And also to remove the mail autogenerate password?

    Or to mail the own password user choose for himself?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘User Registration’ is closed to new replies.