wp_insert_user if user exists

When updating a user with: $user_id = wp_update_user( $userdata ); you need to have the user ID set within $userdata. Also make sure to validate the $user_id output of wp_update_user() as it can be either an integer or an instance of WP_Error, before using it in update_user_meta(). One can use is_wp_error( $user_id ) to check … Read more

I need to verify emails when users signup

I don’t know if it’s any worth, but perhaps you can use the multisite specific activation function, wpmu_activate_signup, as a reference point to get an idea how to handle verification in WordPress. Multisite uses the special wp_signups table to store users waiting for activation. So you might need to create a custom database table, if … Read more

How to auto-generate random numbers in username?

This function would generate a unique user login slug: function my_unique_user_slug( $slug ) { global $wpdb; $check_sql = “SELECT user_login FROM $wpdb->users WHERE user_login = %s LIMIT 1”; if ( ! $wpdb->get_var( $wpdb->prepare( $check_sql, $slug ) ) ) { return $slug; } $suffix = 2; do { $alt_slug = $slug . $suffix; $user_slug_check = $wpdb->get_var( … Read more

Registration form AJAX check for existing username (simple version)

You’re POSTing user_name but in your code you’re checking for register_name, you should instead check $_POST[‘user_name’] instead. You should also be checking to make sure a value is actually being passed as well, this is how I would do it instead (setting unavailable as default): function mpl_check_username() { $response = array( ‘status’ => ‘unavailable’, ‘text’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)